Maritime Fiction
marfictwiki
https://marfict.miraheze.org/wiki/Main_Page
MediaWiki 1.40.1
first-letter
Media
Special
Talk
User
User talk
Maritime Fiction
Maritime Fiction talk
File
File talk
MediaWiki
MediaWiki talk
Template
Template talk
Help
Help talk
Category
Category talk
Campaign
Campaign talk
Module
Module talk
Template:Shipboxflag
10
111
225
2013-10-19T13:30:54Z
w>WOSlinker
0
Changed protection level of Template:Shipboxflag: allow template editors to modify ([Edit=Protected template] (indefinite) [Move=Protected template] (indefinite))
wikitext
text/x-wiki
{{country data {{{1|}}}|shipboxflag/core|variant={{{variant|{{{2|}}}}}}}}<noinclude>{{documentation}}</noinclude>
99dee7c080f10fd8bb6dd9989c03591ec12114f0
Template:Shipboxflag/core
10
112
227
2013-10-19T13:30:56Z
w>WOSlinker
0
Changed protection level of Template:Shipboxflag/core: allow template editors to modify ([Edit=Protected template] (indefinite) [Move=Protected template] (indefinite))
wikitext
text/x-wiki
<span class="flagicon">[[File:{{{flag alias-{{{variant}}}|{{{flag alias}}}}}}|100x35px|alt=|link=]]</span><noinclude>{{documentation}}</noinclude>
be8e637c9f45a421d95f27dd17c5db2a8513813f
Template:1x
10
147
297
2013-11-02T02:28:41Z
w>Fuhghettaboutit
0
Changed protection level of Template:1x: Enable access by template editors ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))
wikitext
text/x-wiki
{{{1}}}<noinclude>
{{documentation}}
</noinclude>
da9241fe72a0821a30e22604f4284d06c326190e
Template:WPMILHIST Infobox style
10
97
197
2014-10-07T15:24:52Z
w>Jackmcbarn
0
make main_box piggyback off of main_box_raw
wikitext
text/x-wiki
<includeonly>{{#switch:{{{1|}}}
|main_box=class="{{#if:{{{2|}}}|infobox {{{2}}}|infobox}}" style="{{#invoke:Data|Module:WPMILHIST Infobox style|main_box_raw}}"
|{{#invoke:Data|Module:WPMILHIST Infobox style|{{{1|}}}}}
}}</includeonly><noinclude>
{{documentation}}
</noinclude>
b117547056afc703e2f1371497b0a53fa5a22751
Template:Div col end
10
47
97
2015-10-03T15:58:07Z
Template>NeilN
0
Changed protection level of Template:Div col end: per request at [[WP:RFPP]] ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))
wikitext
text/x-wiki
<includeonly></div></includeonly><noinclude>
{{Documentation|Template:Div col/doc}}
</noinclude>
78088d41c21d779e3722f220fcc9773dfbbc1e4f
Template:Nowrap
10
124
251
2015-11-28T10:13:53Z
w>Edokter
0
Adapt comment; edits inside noinclude blocks should not affect job queue, but won't kill parser either way.
wikitext
text/x-wiki
<span class="nowrap">{{{1}}}</span><noinclude>
{{documentation}}
<!-- Categories go on the /doc page; interwikis go to Wikidata. -->
</noinclude>
5d0dc6b6d89b37f4356242404f46138a4017f015
Template:Section link
10
127
257
2017-01-17T01:29:39Z
w>Primefac
0
done
wikitext
text/x-wiki
{{#invoke:Section link|main}}<noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
8d047e5845f8a9b74a4655b5dd79ca7595a8f88b
Template:-
10
92
187
2017-03-12T14:41:31Z
w>Paine Ellsworth
0
add [[WP:RCAT|rcat]]
wikitext
text/x-wiki
#REDIRECT [[Template:Clear]]
{{Redirect category shell|
{{R from modification}}
{{R from template shortcut}}
}}
3fb0b377ebee11659e4a3ba0034f60898dbc473f
Template:Ping
10
143
289
2017-03-26T13:07:18Z
w>Jo-Jo Eumerus
0
Per talk page request
wikitext
text/x-wiki
#REDIRECT [[Template:Reply to]]
{{Redirect category shell|
{{R from template shortcut}}
}}
6284a6c588bec5d4885fa23cd56f6535b7fc596f
Template:Strong
10
156
328
2017-09-16T03:10:40Z
w>Matt Fitzpatrick
0
added role parameter and attribute
wikitext
text/x-wiki
<strong {{#if:{{{role|}}}|role="{{{role}}}"}} {{#if:{{{class|}}}|class="{{{class}}}"}} {{#if:{{{id|}}}|id="{{{id}}}"}} {{#if:{{{style|}}}|style="{{{style}}}"}} {{#if:{{{title|}}}|title="{{{title}}}"}}>{{{1}}}</strong><noinclude>
{{documentation}}
<!-- Add cats and interwikis to the /doc subpage, not here! -->
</noinclude>
a6c6d3b520e2018e19376e2f0e1a72801336d1df
Template:Further information
10
104
211
2017-12-09T03:53:22Z
w>Alex 21
0
Changed redirect target from [[Template:Further information]] to [[Template:Further]]
wikitext
text/x-wiki
#REDIRECT [[Template:Further]]
{{R from move}}
42879303989bb2724f884c7b099077b50c789c48
Template:Yesno-no
10
48
99
2018-02-13T20:27:17Z
Template>WOSlinker
0
separate pp-template not needed
wikitext
text/x-wiki
{{safesubst:<noinclude />yesno|{{{1}}}|yes={{{yes|yes}}}|no={{{no|no}}}|blank={{{blank|no}}}|¬={{{¬|no}}}|def={{{def|no}}}}}<noinclude>
{{Documentation|Template:Yesno/doc}}
<!--Categories go in the doc page referenced above; interwikis go in Wikidata.-->
</noinclude>
1ad7b7800da1b867ead8f6ff8cef76e6201b3b56
Module:Distinguish
828
29
61
2018-04-01T10:06:10Z
Template>Galobtter
0
fixed with text and selfref
Scribunto
text/plain
local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local mTableTools --initialize lazily
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}
function p.distinguish(frame)
mArguments = require('Module:Arguments')
mTableTools = require('Module:TableTools')
local args = mArguments.getArgs(frame)
local selfref = args.selfref
local text = args.text
args = mTableTools.compressSparseArray(args)
return p._distinguish(args, text, selfref)
end
function p._distinguish(args, text, selfref)
checkType("_distinguish", 1, args, 'table')
if #args == 0 and not text then return '' end
local text = string.format(
'Not to be confused with %s.',
text or mHatlist.orList(args, true)
)
hnOptions = {selfref = selfref}
return mHatnote._hatnote(text, hnOptions)
end
return p
0364d14af01fc656ad1d898c5036fbd12a7ca938
Template:Param
10
136
275
2018-05-27T03:56:56Z
w>JJMC89
0
clean subst
wikitext
text/x-wiki
{{SAFESUBST:<noinclude />#ifeq:{{SAFESUBST:<noinclude />Yesno|{{{nested|no}}}}}|yes||<{{{tag|code}}}>}}{{{{{{1<noinclude>|foo</noinclude>}}}{{SAFESUBST:<noinclude />#ifeq:{{{2}}}|{{{2|}}} ||}}{{{2|}}}}}}{{SAFESUBST:<noinclude />#ifeq:{{SAFESUBST:<noinclude />Yesno|{{{nested|no}}}}}|yes||</{{{tag|code}}}>}}<noinclude>
{{Documentation}}
<!--
PLEASE ADD CATEGORIES AND INTERWIKIS
TO THE /doc SUBPAGE, THANKS
-->
</noinclude>
abdb5d7fe0982064ea62ad15e8298d1693ed69e2
Module:Reply to
828
144
291
2018-07-04T01:38:15Z
w>Ahecht
0
cleanup code
Scribunto
text/plain
local p = {}
local function makeError(msg)
msg ='Error in [[Template:Reply to]]: ' .. msg
return mw.text.tag('strong', {['class']='error'}, msg)
end
function p.replyto(frame)
local origArgs = frame:getParent().args
local args = {}
local maxArg = 1
local usernames = 0
for k, v in pairs(origArgs) do
if type(k) == 'number' then
if mw.ustring.match(v,'%S') then
if k > maxArg then maxArg = k end
usernames = usernames + 1
local title = mw.title.new(v)
if not title then return makeError('Input contains forbidden characters.') end
args[k] = title.rootText
end
elseif v == '' and k:sub(0,5) == 'label' then
args[k] = '​'
else
args[k] = v
end
end
if usernames > (tonumber(frame.args.max) or 50) then
return makeError(string.format(
'More than %s names specified.',
tostring(frame.args.max or 50)
))
else
if usernames < 1 then
if frame.args.example then args[1] = frame.args.example else return makeError('Username not given.') end
end
args['label1'] = args['label1'] or args['label']
local isfirst = true
local outStr = args['prefix'] or '@'
for i = 1, maxArg do
if args[i] then
if isfirst then
isfirst = false
else
if ( (usernames > 2) or ((usernames == 2) and (args['c'] == '')) ) then outStr = outStr..', ' end
if i == maxArg then outStr = outStr..' '..(args['c'] or 'and') .. ' ' end
end
outStr = string.format(
'%s[[User:%s|%s]]',
outStr,
args[i],
args['label'..tostring(i)] or args[i]
)
end
end
outStr = outStr..(args['p'] or ':')
return mw.text.tag('span', {['class']='template-ping'}, outStr)
end
end
return p
14f0cd73a8a9f122c0e0e15382219083c602c62a
Template:Tag
10
130
263
2018-07-26T17:17:13Z
w>SMcCandlish
0
These are called attributes; no one who does HTML calls them "parameters".
wikitext
text/x-wiki
<code class="{{#ifeq:{{{wrap|}}}|yes|wrap|nowrap}}" style="{{#ifeq:{{{style|}}}|plain|border:none;background:transparent;|{{{style|}}}}}"><!--
Opening tag
-->{{#switch:{{{2|pair}}}
|c|close =
|e|empty|s|single|v|void
|o|open
|p|pair = <{{#if:{{{link|}}}|[[HTML element#{{{1|tag}}}|{{{1|tag}}}]]|{{{1|tag}}}}}{{#if:{{{params|{{{attribs|}}}}}}| {{{params|{{{attribs}}}}}}}}
}}<!--
Content between tags
-->{{#switch:{{{2|pair}}}
|c|close = {{{content|}}}
|e|empty|s|single|v|void =  />
|o|open = >{{{content|}}}
|p|pair = {{#ifeq:{{{1|tag}}}|!--||>}}{{{content|...}}}
}}<!--
Closing tag
-->{{#switch:{{{2|pair}}}
|e|empty|s|single|v|void
|o|open =
|c|close
|p|pair = {{#ifeq:{{{1|tag}}}|!--|-->|</{{{1|tag}}}>}}
}}<!--
--></code><noinclude>
{{Documentation}}
</noinclude>
eae208bc1612c834de697fa3ee9b343966cf8602
Template:Further
10
96
195
2018-07-27T17:29:22Z
w>Galobtter
0
fix so that don't need [[Module:Further]] anymore
wikitext
text/x-wiki
<includeonly>{{#invoke:labelled list hatnote|labelledList|Further information{{#if:{{{topic|}}}| on {{{topic|}}}}}}}</includeonly><noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->
</noinclude>
dd29c6dfb3894a2dc3f20144a654b7012c9a9214
Template:Infobox
10
5
13
2018-08-15T18:33:36Z
Template>Primefac
0
Undid revision 855063393 by [[Special:Contributions/Jdlrobson|Jdlrobson]] ([[User talk:Jdlrobson|talk]]) rather problematic change mentioned [[Template_talk:Infobox#Using_template_styles_to_reduce_technical_debt_inside_mobile_skin|on talk page]], reverting until it can be sorted
wikitext
text/x-wiki
{{#invoke:Infobox|infobox}}<includeonly>{{template other|{{#ifeq:{{PAGENAME}}|Infobox||{{#ifeq:{{str left|{{SUBPAGENAME}}|7}}|Infobox|[[Category:Infobox templates|{{remove first word|{{SUBPAGENAME}}}}]]}}}}|}}</includeonly><noinclude>
{{documentation}}
<!-- Categories go in the /doc subpage, and interwikis go in Wikidata. -->
</noinclude>
817a9f5b6524eced06a57bd1d5fd7179f9369bf2
Module:WPMILHIST Infobox style
828
99
201
2018-09-21T22:30:21Z
w>Frietjes
0
slightly larger for [[Operation Fritham]]
Scribunto
text/plain
local retval = {
main_box_raw_auto_width = 'border-spacing:2px;',
header_raw = 'background-color:#C3D6EF;text-align:center;vertical-align:middle;font-size:110%;',
sub_header_raw = 'background-color:#DCDCDC;text-align:center;vertical-align:middle;',
header_color = 'background-color:#C3D6EF;',
nav_box = 'margin:0;float:right;clear:right;width:25.5em;margin-bottom:0.5em;margin-left:1em;',
nav_box_child = 'margin:0;float:right;clear:right;width:25em;margin-bottom:0.5em;',
nav_box_wide = '',
nav_box_header = 'background-color:#C3D6EF;',
nav_box_wide_header = 'background-color:#C3D6EF;',
nav_box_label = 'background-color:#DCDCDC;',
image_box_raw = 'text-align:center;border-bottom:1px solid #aaa;line-height:1.5em;',
image_box_plain_raw = 'text-align:center;line-height:1.5em;',
internal_border = '1px dotted #aaa;',
section_border = '1px solid #aaa;'
}
retval.main_box_raw = 'width:25.5em;' .. retval.main_box_raw_auto_width
retval.header_bar = 'style="' .. retval.header_raw .. '"'
retval.sub_header_bar = 'style="' .. retval.sub_header_raw .. '"'
retval.image_box = 'style="' .. retval.image_box_raw .. '"'
retval.image_box_plain = 'style="' .. retval.image_box_plain_raw .. '"'
return retval
0f9ea47bc17e40cdabbae6de54f63e40ae502f8e
Template:Nobold
10
15
33
2018-10-23T17:15:13Z
Template>Frietjes
0
wikitext
text/x-wiki
<templatestyles src="Nobold/styles.css"/><span class="nobold">{{{1}}}</span><noinclude>
{{documentation}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS -->
</noinclude>
9c92b5951772bb26ca0fbe9256418b65e47700dd
Template:Template other
10
25
53
2018-12-16T22:06:25Z
Template>Amorymeltzer
0
Changed protection level for "[[Template:Template other]]": [[WP:High-risk templates|Highly visible template]]: Transclusion count has increased dramatically ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))
wikitext
text/x-wiki
{{#switch:
<!--If no or empty "demospace" parameter then detect namespace-->
{{#if:{{{demospace|}}}
| {{lc: {{{demospace}}} }} <!--Use lower case "demospace"-->
| {{#ifeq:{{NAMESPACE}}|{{ns:Template}}
| template
| other
}}
}}
| template = {{{1|}}}
| other
| #default = {{{2|}}}
}}<!--End switch--><noinclude>
{{documentation}}
<!-- Add categories and interwikis to the /doc subpage, not here! -->
</noinclude>
06fb13d264df967b5232141067eb7d2b67372d76
Template:Nobold/styles.css
10
16
35
2019-03-03T23:43:41Z
Template>Pppery
0
Adding protection template
text
text/plain
/* {{pp-template}} */
/* Styling for Template:Nobold */
.nobold {
font-weight: normal;
}
83e5f0adacf8c7984251f1fd9d11ed82ebaadf03
Template:Lua
10
65
133
2019-03-20T22:04:45Z
Template>RMCD bot
0
Removing notice of move discussion
wikitext
text/x-wiki
<includeonly>{{#invoke:Lua banner|main}}</includeonly><noinclude>
{{Lua|Module:Lua banner}}
{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
dba3962144dacd289dbc34f50fbe0a7bf6d7f2f7
Template:Clc
10
77
157
2019-04-24T04:30:59Z
Template>JJMC89
0
actual template is in the category
wikitext
text/x-wiki
#REDIRECT [[Template:Category link with count]]
02280e2ab57b544236e11f913e3759c5781ca9d5
Template:YMD to ISO
10
115
233
2019-04-28T19:21:56Z
w>El C
0
Protected "[[Template:YMD to ISO]]": [[WP:High-risk templates|Highly visible template]] ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
wikitext
text/x-wiki
{{#invoke:YMD to ISO|main|{{{1|}}}}}<noinclude>
{{Documentation}}
</noinclude>
30d1e18baa22a6e88743a6f71bbc166ceced5ddb
Template:USN flag
10
113
229
2019-06-23T18:32:50Z
w>Primefac
0
fixing flag again
wikitext
text/x-wiki
<span class="flagicon">[[File:{{#ifexpr: {{{1|9999}}} >= 1960|Flag of the United States
|{{#ifexpr: {{{1|9999}}} >= 1959|US flag 49 stars
|{{#ifexpr: {{{1|9999}}} >= 1912|US flag 48 stars
|{{#ifexpr: {{{1|9999}}} >= 1908|US flag 46 stars
|{{#ifexpr: {{{1|9999}}} >= 1896|US flag 45 stars
|{{#ifexpr: {{{1|9999}}} >= 1891|US flag 44 stars
|{{#ifexpr: {{{1|9999}}} >= 1890|US flag 43 stars
|{{#ifexpr: {{{1|9999}}} >= 1877|US flag 38 stars
|{{#ifexpr: {{{1|9999}}} >= 1867|US flag 37 stars
|{{#ifexpr: {{{1|9999}}} >= 1865|US flag 36 stars
|{{#ifexpr: {{{1|9999}}} >= 1863|US flag 35 stars
|{{#ifexpr: {{{1|9999}}} >= 1861|US flag 34 stars
|{{#ifexpr: {{{1|9999}}} >= 1859|US flag 33 stars
|{{#ifexpr: {{{1|9999}}} >= 1858|US flag 32 stars
|{{#ifexpr: {{{1|9999}}} >= 1851|US flag 31 stars
|{{#ifexpr: {{{1|9999}}} >= 1848|US flag 30 stars
|{{#ifexpr: {{{1|9999}}} >= 1847|US flag 29 stars
|{{#ifexpr: {{{1|9999}}} >= 1846|US flag 28 stars
|{{#ifexpr: {{{1|9999}}} >= 1845|US flag 27 stars
|{{#ifexpr: {{{1|9999}}} >= 1837|US flag 26 stars
|{{#ifexpr: {{{1|9999}}} >= 1836|US flag 25 stars
|{{#ifexpr: {{{1|9999}}} >= 1822|US flag 24 stars
|{{#ifexpr: {{{1|9999}}} >= 1820|US flag 23 stars
|{{#ifexpr: {{{1|9999}}} >= 1819|US flag 21 stars
|{{#ifexpr: {{{1|9999}}} >= 1818|US flag 20 stars
|{{#ifexpr: {{{1|9999}}} >= 1795|US flag 15 stars
|{{#ifexpr: {{{1|9999}}} >= 1777|US flag 13 stars
|{{#ifexpr: {{{1|9999}}} >= 1775|Flag of the United States (1776–1777)
<!--default if no param-->|Flag of the United States
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}.svg|100x35px|alt=|link=]]</span><noinclude>
{{documentation}}
</noinclude>
7772b3f5c06e3d9391d17be46b57a5db0c546371
Template:Invoke
10
123
249
2019-11-12T22:36:33Z
w>Pppery
0
wikitext
text/x-wiki
<includeonly>{{#invoke:LuaCall|invoke}}</includeonly><noinclude>{{Doc}}</noinclude>
e7254069f4bce95ca8e4bb7ee0797d16c30b3555
Template:Doc
10
148
299
2020-02-27T12:46:09Z
w>MSGJ
0
remove two categories and add rcat shell
wikitext
text/x-wiki
#REDIRECT [[Template:Documentation]]
{{rcat shell|
{{R from template shortcut}}
}}
524178a0a060e3b8757c421009f8c9f4f6b7cc4d
Template:Ombox
10
75
153
2020-04-01T06:12:36Z
Template>MusikAnimal
0
1 revision imported
wikitext
text/x-wiki
{{#invoke:Message box|ombox}}<noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->
</noinclude>
0e54065432d540737b9e56c4e3a8e7f74d4534ea
Module:Arguments
828
8
19
2020-04-01T06:12:40Z
Template>MusikAnimal
0
1 revision imported
Scribunto
text/plain
-- This module provides easy processing of arguments passed to Scribunto from
-- #invoke. It is intended for use by other Lua modules, and should not be
-- called from #invoke directly.
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local arguments = {}
-- Generate four different tidyVal functions, so that we don't have to check the
-- options every time we call it.
local function tidyValDefault(key, val)
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val == '' then
return nil
else
return val
end
else
return val
end
end
local function tidyValTrimOnly(key, val)
if type(val) == 'string' then
return val:match('^%s*(.-)%s*$')
else
return val
end
end
local function tidyValRemoveBlanksOnly(key, val)
if type(val) == 'string' then
if val:find('%S') then
return val
else
return nil
end
else
return val
end
end
local function tidyValNoChange(key, val)
return val
end
local function matchesTitle(given, title)
local tp = type( given )
return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end
local translate_mt = { __index = function(t, k) return k end }
function arguments.getArgs(frame, options)
checkType('getArgs', 1, frame, 'table', true)
checkType('getArgs', 2, options, 'table', true)
frame = frame or {}
options = options or {}
--[[
-- Set up argument translation.
--]]
options.translate = options.translate or {}
if getmetatable(options.translate) == nil then
setmetatable(options.translate, translate_mt)
end
if options.backtranslate == nil then
options.backtranslate = {}
for k,v in pairs(options.translate) do
options.backtranslate[v] = k
end
end
if options.backtranslate and getmetatable(options.backtranslate) == nil then
setmetatable(options.backtranslate, {
__index = function(t, k)
if options.translate[k] ~= k then
return nil
else
return k
end
end
})
end
--[[
-- Get the argument tables. If we were passed a valid frame object, get the
-- frame arguments (fargs) and the parent frame arguments (pargs), depending
-- on the options set and on the parent frame's availability. If we weren't
-- passed a valid frame object, we are being called from another Lua module
-- or from the debug console, so assume that we were passed a table of args
-- directly, and assign it to a new variable (luaArgs).
--]]
local fargs, pargs, luaArgs
if type(frame.args) == 'table' and type(frame.getParent) == 'function' then
if options.wrappers then
--[[
-- The wrappers option makes Module:Arguments look up arguments in
-- either the frame argument table or the parent argument table, but
-- not both. This means that users can use either the #invoke syntax
-- or a wrapper template without the loss of performance associated
-- with looking arguments up in both the frame and the parent frame.
-- Module:Arguments will look up arguments in the parent frame
-- if it finds the parent frame's title in options.wrapper;
-- otherwise it will look up arguments in the frame object passed
-- to getArgs.
--]]
local parent = frame:getParent()
if not parent then
fargs = frame.args
else
local title = parent:getTitle():gsub('/sandbox$', '')
local found = false
if matchesTitle(options.wrappers, title) then
found = true
elseif type(options.wrappers) == 'table' then
for _,v in pairs(options.wrappers) do
if matchesTitle(v, title) then
found = true
break
end
end
end
-- We test for false specifically here so that nil (the default) acts like true.
if found or options.frameOnly == false then
pargs = parent.args
end
if not found or options.parentOnly == false then
fargs = frame.args
end
end
else
-- options.wrapper isn't set, so check the other options.
if not options.parentOnly then
fargs = frame.args
end
if not options.frameOnly then
local parent = frame:getParent()
pargs = parent and parent.args or nil
end
end
if options.parentFirst then
fargs, pargs = pargs, fargs
end
else
luaArgs = frame
end
-- Set the order of precedence of the argument tables. If the variables are
-- nil, nothing will be added to the table, which is how we avoid clashes
-- between the frame/parent args and the Lua args.
local argTables = {fargs}
argTables[#argTables + 1] = pargs
argTables[#argTables + 1] = luaArgs
--[[
-- Generate the tidyVal function. If it has been specified by the user, we
-- use that; if not, we choose one of four functions depending on the
-- options chosen. This is so that we don't have to call the options table
-- every time the function is called.
--]]
local tidyVal = options.valueFunc
if tidyVal then
if type(tidyVal) ~= 'function' then
error(
"bad value assigned to option 'valueFunc'"
.. '(function expected, got '
.. type(tidyVal)
.. ')',
2
)
end
elseif options.trim ~= false then
if options.removeBlanks ~= false then
tidyVal = tidyValDefault
else
tidyVal = tidyValTrimOnly
end
else
if options.removeBlanks ~= false then
tidyVal = tidyValRemoveBlanksOnly
else
tidyVal = tidyValNoChange
end
end
--[[
-- Set up the args, metaArgs and nilArgs tables. args will be the one
-- accessed from functions, and metaArgs will hold the actual arguments. Nil
-- arguments are memoized in nilArgs, and the metatable connects all of them
-- together.
--]]
local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}
setmetatable(args, metatable)
local function mergeArgs(tables)
--[[
-- Accepts multiple tables as input and merges their keys and values
-- into one table. If a value is already present it is not overwritten;
-- tables listed earlier have precedence. We are also memoizing nil
-- values, which can be overwritten if they are 's' (soft).
--]]
for _, t in ipairs(tables) do
for key, val in pairs(t) do
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
local tidiedVal = tidyVal(key, val)
if tidiedVal == nil then
nilArgs[key] = 's'
else
metaArgs[key] = tidiedVal
end
end
end
end
end
--[[
-- Define metatable behaviour. Arguments are memoized in the metaArgs table,
-- and are only fetched from the argument tables once. Fetching arguments
-- from the argument tables is the most resource-intensive step in this
-- module, so we try and avoid it where possible. For this reason, nil
-- arguments are also memoized, in the nilArgs table. Also, we keep a record
-- in the metatable of when pairs and ipairs have been called, so we do not
-- run pairs and ipairs on the argument tables more than once. We also do
-- not run ipairs on fargs and pargs if pairs has already been run, as all
-- the arguments will already have been copied over.
--]]
metatable.__index = function (t, key)
--[[
-- Fetches an argument when the args table is indexed. First we check
-- to see if the value is memoized, and if not we try and fetch it from
-- the argument tables. When we check memoization, we need to check
-- metaArgs before nilArgs, as both can be non-nil at the same time.
-- If the argument is not present in metaArgs, we also check whether
-- pairs has been run yet. If pairs has already been run, we return nil.
-- This is because all the arguments will have already been copied into
-- metaArgs by the mergeArgs function, meaning that any other arguments
-- must be nil.
--]]
if type(key) == 'string' then
key = options.translate[key]
end
local val = metaArgs[key]
if val ~= nil then
return val
elseif metatable.donePairs or nilArgs[key] then
return nil
end
for _, argTable in ipairs(argTables) do
local argTableVal = tidyVal(key, argTable[key])
if argTableVal ~= nil then
metaArgs[key] = argTableVal
return argTableVal
end
end
nilArgs[key] = 'h'
return nil
end
metatable.__newindex = function (t, key, val)
-- This function is called when a module tries to add a new value to the
-- args table, or tries to change an existing value.
if type(key) == 'string' then
key = options.translate[key]
end
if options.readOnly then
error(
'could not write to argument table key "'
.. tostring(key)
.. '"; the table is read-only',
2
)
elseif options.noOverwrite and args[key] ~= nil then
error(
'could not write to argument table key "'
.. tostring(key)
.. '"; overwriting existing arguments is not permitted',
2
)
elseif val == nil then
--[[
-- If the argument is to be overwritten with nil, we need to erase
-- the value in metaArgs, so that __index, __pairs and __ipairs do
-- not use a previous existing value, if present; and we also need
-- to memoize the nil in nilArgs, so that the value isn't looked
-- up in the argument tables if it is accessed again.
--]]
metaArgs[key] = nil
nilArgs[key] = 'h'
else
metaArgs[key] = val
end
end
local function translatenext(invariant)
local k, v = next(invariant.t, invariant.k)
invariant.k = k
if k == nil then
return nil
elseif type(k) ~= 'string' or not options.backtranslate then
return k, v
else
local backtranslate = options.backtranslate[k]
if backtranslate == nil then
-- Skip this one. This is a tail call, so this won't cause stack overflow
return translatenext(invariant)
else
return backtranslate, v
end
end
end
metatable.__pairs = function ()
-- Called when pairs is run on the args table.
if not metatable.donePairs then
mergeArgs(argTables)
metatable.donePairs = true
end
return translatenext, { t = metaArgs }
end
local function inext(t, i)
-- This uses our __index metamethod
local v = t[i + 1]
if v ~= nil then
return i + 1, v
end
end
metatable.__ipairs = function (t)
-- Called when ipairs is run on the args table.
return inext, t, 0
end
return args
end
return arguments
3134ecce8429b810d445e29eae115e2ae4c36c53
Module:Yesno
828
7
17
2020-04-01T06:27:55Z
Template>MusikAnimal
0
Undid revision 948472533 by [[Special:Contributions/w>Vogone|w>Vogone]] ([[User talk:w>Vogone|talk]])
Scribunto
text/plain
-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.
return function (val, default)
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
-- following line.
val = type(val) == 'string' and val:lower() or val
if val == nil then
return nil
elseif val == true
or val == 'yes'
or val == 'y'
or val == 'true'
or val == 't'
or val == 'on'
or tonumber(val) == 1
then
return true
elseif val == false
or val == 'no'
or val == 'n'
or val == 'false'
or val == 'f'
or val == 'off'
or tonumber(val) == 0
then
return false
else
return default
end
end
f767643e7d12126d020d88d662a3dd057817b9dc
Module:File link
828
32
67
2020-04-01T06:31:54Z
Template>MusikAnimal
0
Undid revision 948472508 by [[Special:Contributions/w>IPad365|w>IPad365]] ([[User talk:w>IPad365|talk]])
Scribunto
text/plain
-- This module provides a library for formatting file wikilinks.
local yesno = require('Module:Yesno')
local checkType = require('libraryUtil').checkType
local p = {}
function p._main(args)
checkType('_main', 1, args, 'table')
-- This is basically libraryUtil.checkTypeForNamedArg, but we are rolling our
-- own function to get the right error level.
local function checkArg(key, val, level)
if type(val) ~= 'string' then
error(string.format(
"type error in '%s' parameter of '_main' (expected string, got %s)",
key, type(val)
), level)
end
end
local ret = {}
-- Adds a positional parameter to the buffer.
local function addPositional(key)
local val = args[key]
if not val then
return nil
end
checkArg(key, val, 4)
ret[#ret + 1] = val
end
-- Adds a named parameter to the buffer. We assume that the parameter name
-- is the same as the argument key.
local function addNamed(key)
local val = args[key]
if not val then
return nil
end
checkArg(key, val, 4)
ret[#ret + 1] = key .. '=' .. val
end
-- Filename
checkArg('file', args.file, 3)
ret[#ret + 1] = 'File:' .. args.file
-- Format
if args.format then
checkArg('format', args.format)
if args.formatfile then
checkArg('formatfile', args.formatfile)
ret[#ret + 1] = args.format .. '=' .. args.formatfile
else
ret[#ret + 1] = args.format
end
end
-- Border
if yesno(args.border) then
ret[#ret + 1] = 'border'
end
addPositional('location')
addPositional('alignment')
addPositional('size')
addNamed('upright')
addNamed('link')
addNamed('alt')
addNamed('page')
addNamed('class')
addNamed('lang')
addNamed('start')
addNamed('end')
addNamed('thumbtime')
addPositional('caption')
return string.format('[[%s]]', table.concat(ret, '|'))
end
function p.main(frame)
local origArgs = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:File link'
})
if not origArgs.file then
error("'file' parameter missing from [[Template:File link]]", 0)
end
-- Copy the arguments that were passed to a new table to avoid looking up
-- every possible parameter in the frame object.
local args = {}
for k, v in pairs(origArgs) do
-- Make _BLANK a special argument to add a blank parameter. For use in
-- conditional templates etc. it is useful for blank arguments to be
-- ignored, but we still need a way to specify them so that we can do
-- things like [[File:Example.png|link=]].
if v == '_BLANK' then
v = ''
end
args[k] = v
end
return p._main(args)
end
return p
66925f088d11530f2482f04181a3baaaa0ad3d0c
Template:Sandbox other
10
54
111
2020-04-03T00:08:09Z
Template>Evad37
0
Also match subpage names beginning with "sandbox", per [[Template_talk:Sandbox_other#Template-protected_edit_request_on_28_March_2020|edit request]]
wikitext
text/x-wiki
{{#if:{{#ifeq:{{#invoke:String|sublength|s={{SUBPAGENAME}}|i=0|len=7}}|sandbox|1}}{{#ifeq:{{SUBPAGENAME}}|doc|1}}{{#invoke:String|match|{{PAGENAME}}|/sandbox/styles.css$|plain=false|nomatch=}}|{{{1|}}}|{{{2|}}}}}<!--
--><noinclude>{{documentation}}</noinclude>
91e4ae891d6b791615152c1fbc971414961ba872
Template:Tlf
10
57
117
2020-04-13T14:42:57Z
Template>Primefac
0
Primefac moved page [[Template:Tlf]] to [[Template:Template link with link off]]: full name to indicate what it does
wikitext
text/x-wiki
#REDIRECT [[Template:Template link with link off]]
{{Redirect category shell|
{{R from move}}
}}
52759e1d3f7c9aa4a03d0b7d4f84f4c6adf53edf
Template:Sidebar
10
28
59
2020-06-04T02:43:13Z
Template>Primefac
0
TFD closed as keep ([[WP:XFDC|XFDcloser]])
wikitext
text/x-wiki
{{#invoke:Sidebar|sidebar}}<noinclude>
{{documentation}}</noinclude>
ab2498000a99daf324f656b0badd187b4a3e2b42
Template:Invoke/doc
10
150
303
2020-07-07T17:24:24Z
w>Jonesey95
0
replace deprecated source tags
wikitext
text/x-wiki
{{Documentation subpage}}
{{lua|Module:LuaCall}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
This template can be used to debug template parameters.
== Usage ==
* {<!---->{{{BASEPAGENAME}}|''module name''|''function name''|''arguments ...''}}
== Example ==
* {<!---->{{{BASEPAGENAME}}|math|random}} --> {{{{BASEPAGENAME}}|math|random}}
* {<!---->{{{BASEPAGENAME}}|math|min|9|7|8}} --> {{{{BASEPAGENAME}}|math|min|9|7|8}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject| arg1 |unnamed parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject| arg1 |unnamed parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4= arg1 |5=named parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4= arg1 |5=named parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject| ''<newline>''arg1''<newline>'' |unnamed parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|
arg1
|unnamed parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4= ''<newline>''arg1''<newline>'' |5=named parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4=
arg1
|5=named parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|''<newline>'' arg1 ''<newline>''|unnamed parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|
arg1
|unnamed parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4=''<newline>'' arg1 ''<newline>''|5=named parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4=
arg1
|5=named parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|&lt;&gt;}} {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.logObject|&lt;&gt;}} {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|&lt;&gt;}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|<>}} {{{{BASEPAGENAME}}|LuaCall|call|mw.logObject|<>}} {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<pre>pre text</pre>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<pre>pre text</pre>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<nowiki>nowiki text</nowiki>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<nowiki>nowiki text</nowiki>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<ref>ref text</ref>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<ref>ref text</ref>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<code>code text</code>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<code>code text</code>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<syntaxhighlight lang=php>source text</syntaxhighlight>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<syntaxhighlight lang=php>source text</syntaxhighlight>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|{<!---->{ping|User1}}}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|{{ping|User1}}}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<nowiki>[[</nowiki>User:User1]]}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|[[User:User1]]}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<ref>ref then <nowiki>nowiki</nowiki></ref>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<ref>ref then <nowiki>nowiki</nowiki></ref>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<pre>pre then <nowiki>nowiki</nowiki></pre>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<pre>pre then <nowiki>nowiki</nowiki></pre>}}
* {<!-- -->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<nowiki>{{replace|<tag>tag text</tag>|tag|pre}}{{replace|<tag>tag text</tag>|tag|nowiki}}{{replace|<tag>tag text</tag>|tag|ref}}{{replace|<tag>tag text</tag>|tag|code}}{{replace|1=<tag lang=php>tag text</tag>|2=tag|3=syntaxhighlight}}</nowiki>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|{{replace|<tag>tag text</tag>|tag|pre}}{{replace|<tag>tag text</tag>|tag|nowiki}}{{replace|<tag>tag text</tag>|tag|ref}}{{replace|<tag>tag text</tag>|tag|code}}{{replace|1=<tag lang=php>tag text</tag>|2=tag|3=syntaxhighlight}}}}
* {<!-- -->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|4={<!-- -->{1x|<}}pre>pre text</pre>{<!-- -->{1x|<}}nowiki>nowiki text</nowiki>{<!-- -->{1x|<}}ref>ref text</ref>{<!-- -->{1x|<}}code>code text</code>{<!-- -->{1x|<}}syntaxhighlight lang=php>source text</syntaxhighlight>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|4={{1x|<}}pre>pre text</pre>{{1x|<}}nowiki>nowiki text</nowiki>{{1x|<}}ref>ref text</ref>{{1x|<}}code>code text</code>{{1x|<}}syntaxhighlight lang=php>source text</syntaxhighlight>}}
<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
}}</includeonly>
6a343380b757a59de1283ae8a790e7cf4599ac8f
Module:String
828
18
39
2020-08-02T15:49:42Z
Template>RexxS
0
separate annotations for str.match from those for str._match
Scribunto
text/plain
--[[
This module is intended to provide access to basic string functions.
Most of the functions provided here can be invoked with named parameters,
unnamed parameters, or a mixture. If named parameters are used, Mediawiki will
automatically remove any leading or trailing whitespace from the parameter.
Depending on the intended use, it may be advantageous to either preserve or
remove such whitespace.
Global options
ignore_errors: If set to 'true' or 1, any error condition will result in
an empty string being returned rather than an error message.
error_category: If an error occurs, specifies the name of a category to
include with the error message. The default category is
[Category:Errors reported by Module String].
no_category: If set to 'true' or 1, no category will be added if an error
is generated.
Unit tests for this module are available at Module:String/tests.
]]
local str = {}
--[[
len
This function returns the length of the target string.
Usage:
{{#invoke:String|len|target_string|}}
OR
{{#invoke:String|len|s=target_string}}
Parameters
s: The string whose length to report
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from the target string.
]]
function str.len( frame )
local new_args = str._getParameters( frame.args, {'s'} )
local s = new_args['s'] or ''
return mw.ustring.len( s )
end
--[[
sub
This function returns a substring of the target string at specified indices.
Usage:
{{#invoke:String|sub|target_string|start_index|end_index}}
OR
{{#invoke:String|sub|s=target_string|i=start_index|j=end_index}}
Parameters
s: The string to return a subset of
i: The fist index of the substring to return, defaults to 1.
j: The last index of the string to return, defaults to the last character.
The first character of the string is assigned an index of 1. If either i or j
is a negative value, it is interpreted the same as selecting a character by
counting from the end of the string. Hence, a value of -1 is the same as
selecting the last character of the string.
If the requested indices are out of range for the given string, an error is
reported.
]]
function str.sub( frame )
local new_args = str._getParameters( frame.args, { 's', 'i', 'j' } )
local s = new_args['s'] or ''
local i = tonumber( new_args['i'] ) or 1
local j = tonumber( new_args['j'] ) or -1
local len = mw.ustring.len( s )
-- Convert negatives for range checking
if i < 0 then
i = len + i + 1
end
if j < 0 then
j = len + j + 1
end
if i > len or j > len or i < 1 or j < 1 then
return str._error( 'String subset index out of range' )
end
if j < i then
return str._error( 'String subset indices out of order' )
end
return mw.ustring.sub( s, i, j )
end
--[[
This function implements that features of {{str sub old}} and is kept in order
to maintain these older templates.
]]
function str.sublength( frame )
local i = tonumber( frame.args.i ) or 0
local len = tonumber( frame.args.len )
return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) )
end
--[[
_match
This function returns a substring from the source string that matches a
specified pattern. It is exported for use in other modules
Usage:
strmatch = require("Module:String")._match
sresult = strmatch( s, pattern, start, match, plain, nomatch )
Parameters
s: The string to search
pattern: The pattern or string to find within the string
start: The index within the source string to start the search. The first
character of the string has index 1. Defaults to 1.
match: In some cases it may be possible to make multiple matches on a single
string. This specifies which match to return, where the first match is
match= 1. If a negative number is specified then a match is returned
counting from the last match. Hence match = -1 is the same as requesting
the last match. Defaults to 1.
plain: A flag indicating that the pattern should be understood as plain
text. Defaults to false.
nomatch: If no match is found, output the "nomatch" value rather than an error.
For information on constructing Lua patterns, a form of [regular expression], see:
* http://www.lua.org/manual/5.1/manual.html#5.4.1
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns
]]
-- This sub-routine is exported for use in other modules
function str._match( s, pattern, start, match_index, plain_flag, nomatch )
if s == '' then
return str._error( 'Target string is empty' )
end
if pattern == '' then
return str._error( 'Pattern string is empty' )
end
start = tonumber(start) or 1
if math.abs(start) < 1 or math.abs(start) > mw.ustring.len( s ) then
return str._error( 'Requested start is out of range' )
end
if match_index == 0 then
return str._error( 'Match index is out of range' )
end
if plain_flag then
pattern = str._escapePattern( pattern )
end
local result
if match_index == 1 then
-- Find first match is simple case
result = mw.ustring.match( s, pattern, start )
else
if start > 1 then
s = mw.ustring.sub( s, start )
end
local iterator = mw.ustring.gmatch(s, pattern)
if match_index > 0 then
-- Forward search
for w in iterator do
match_index = match_index - 1
if match_index == 0 then
result = w
break
end
end
else
-- Reverse search
local result_table = {}
local count = 1
for w in iterator do
result_table[count] = w
count = count + 1
end
result = result_table[ count + match_index ]
end
end
if result == nil then
if nomatch == nil then
return str._error( 'Match not found' )
else
return nomatch
end
else
return result
end
end
--[[
match
This function returns a substring from the source string that matches a
specified pattern.
Usage:
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}
OR
{{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index
|match=match_number|plain=plain_flag|nomatch=nomatch_output}}
Parameters
s: The string to search
pattern: The pattern or string to find within the string
start: The index within the source string to start the search. The first
character of the string has index 1. Defaults to 1.
match: In some cases it may be possible to make multiple matches on a single
string. This specifies which match to return, where the first match is
match= 1. If a negative number is specified then a match is returned
counting from the last match. Hence match = -1 is the same as requesting
the last match. Defaults to 1.
plain: A flag indicating that the pattern should be understood as plain
text. Defaults to false.
nomatch: If no match is found, output the "nomatch" value rather than an error.
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from each string. In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
If the match_number or start_index are out of range for the string being queried, then
this function generates an error. An error is also generated if no match is found.
If one adds the parameter ignore_errors=true, then the error will be suppressed and
an empty string will be returned on any failure.
For information on constructing Lua patterns, a form of [regular expression], see:
* http://www.lua.org/manual/5.1/manual.html#5.4.1
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns
]]
-- This is the entry point for #invoke:String|match
function str.match( frame )
local new_args = str._getParameters( frame.args, {'s', 'pattern', 'start', 'match', 'plain', 'nomatch'} )
local s = new_args['s'] or ''
local start = tonumber( new_args['start'] ) or 1
local plain_flag = str._getBoolean( new_args['plain'] or false )
local pattern = new_args['pattern'] or ''
local match_index = math.floor( tonumber(new_args['match']) or 1 )
local nomatch = new_args['nomatch']
return str._match( s, pattern, start, match_index, plain_flag, nomatch )
end
--[[
pos
This function returns a single character from the target string at position pos.
Usage:
{{#invoke:String|pos|target_string|index_value}}
OR
{{#invoke:String|pos|target=target_string|pos=index_value}}
Parameters
target: The string to search
pos: The index for the character to return
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from the target string. In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
The first character has an index value of 1.
If one requests a negative value, this function will select a character by counting backwards
from the end of the string. In other words pos = -1 is the same as asking for the last character.
A requested value of zero, or a value greater than the length of the string returns an error.
]]
function str.pos( frame )
local new_args = str._getParameters( frame.args, {'target', 'pos'} )
local target_str = new_args['target'] or ''
local pos = tonumber( new_args['pos'] ) or 0
if pos == 0 or math.abs(pos) > mw.ustring.len( target_str ) then
return str._error( 'String index out of range' )
end
return mw.ustring.sub( target_str, pos, pos )
end
--[[
str_find
This function duplicates the behavior of {{str_find}}, including all of its quirks.
This is provided in order to support existing templates, but is NOT RECOMMENDED for
new code and templates. New code is recommended to use the "find" function instead.
Returns the first index in "source" that is a match to "target". Indexing is 1-based,
and the function returns -1 if the "target" string is not present in "source".
Important Note: If the "target" string is empty / missing, this function returns a
value of "1", which is generally unexpected behavior, and must be accounted for
separatetly.
]]
function str.str_find( frame )
local new_args = str._getParameters( frame.args, {'source', 'target'} )
local source_str = new_args['source'] or ''
local target_str = new_args['target'] or ''
if target_str == '' then
return 1
end
local start = mw.ustring.find( source_str, target_str, 1, true )
if start == nil then
start = -1
end
return start
end
--[[
find
This function allows one to search for a target string or pattern within another
string.
Usage:
{{#invoke:String|find|source_str|target_string|start_index|plain_flag}}
OR
{{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}}
Parameters
source: The string to search
target: The string or pattern to find within source
start: The index within the source string to start the search, defaults to 1
plain: Boolean flag indicating that target should be understood as plain
text and not as a Lua style regular expression, defaults to true
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from the parameter. In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
This function returns the first index >= "start" where "target" can be found
within "source". Indices are 1-based. If "target" is not found, then this
function returns 0. If either "source" or "target" are missing / empty, this
function also returns 0.
This function should be safe for UTF-8 strings.
]]
function str.find( frame )
local new_args = str._getParameters( frame.args, {'source', 'target', 'start', 'plain' } )
local source_str = new_args['source'] or ''
local pattern = new_args['target'] or ''
local start_pos = tonumber(new_args['start']) or 1
local plain = new_args['plain'] or true
if source_str == '' or pattern == '' then
return 0
end
plain = str._getBoolean( plain )
local start = mw.ustring.find( source_str, pattern, start_pos, plain )
if start == nil then
start = 0
end
return start
end
--[[
replace
This function allows one to replace a target string or pattern within another
string.
Usage:
{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}}
OR
{{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string|
count=replacement_count|plain=plain_flag}}
Parameters
source: The string to search
pattern: The string or pattern to find within source
replace: The replacement text
count: The number of occurences to replace, defaults to all.
plain: Boolean flag indicating that pattern should be understood as plain
text and not as a Lua style regular expression, defaults to true
]]
function str.replace( frame )
local new_args = str._getParameters( frame.args, {'source', 'pattern', 'replace', 'count', 'plain' } )
local source_str = new_args['source'] or ''
local pattern = new_args['pattern'] or ''
local replace = new_args['replace'] or ''
local count = tonumber( new_args['count'] )
local plain = new_args['plain'] or true
if source_str == '' or pattern == '' then
return source_str
end
plain = str._getBoolean( plain )
if plain then
pattern = str._escapePattern( pattern )
replace = mw.ustring.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences.
end
local result
if count ~= nil then
result = mw.ustring.gsub( source_str, pattern, replace, count )
else
result = mw.ustring.gsub( source_str, pattern, replace )
end
return result
end
--[[
simple function to pipe string.rep to templates.
]]
function str.rep( frame )
local repetitions = tonumber( frame.args[2] )
if not repetitions then
return str._error( 'function rep expects a number as second parameter, received "' .. ( frame.args[2] or '' ) .. '"' )
end
return string.rep( frame.args[1] or '', repetitions )
end
--[[
escapePattern
This function escapes special characters from a Lua string pattern. See [1]
for details on how patterns work.
[1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
Usage:
{{#invoke:String|escapePattern|pattern_string}}
Parameters
pattern_string: The pattern string to escape.
]]
function str.escapePattern( frame )
local pattern_str = frame.args[1]
if not pattern_str then
return str._error( 'No pattern string specified' )
end
local result = str._escapePattern( pattern_str )
return result
end
--[[
count
This function counts the number of occurrences of one string in another.
]]
function str.count(frame)
local args = str._getParameters(frame.args, {'source', 'pattern', 'plain'})
local source = args.source or ''
local pattern = args.pattern or ''
local plain = str._getBoolean(args.plain or true)
if plain then
pattern = str._escapePattern(pattern)
end
local _, count = mw.ustring.gsub(source, pattern, '')
return count
end
--[[
endswith
This function determines whether a string ends with another string.
]]
function str.endswith(frame)
local args = str._getParameters(frame.args, {'source', 'pattern'})
local source = args.source or ''
local pattern = args.pattern or ''
if pattern == '' then
-- All strings end with the empty string.
return "yes"
end
if mw.ustring.sub(source, -mw.ustring.len(pattern), -1) == pattern then
return "yes"
else
return ""
end
end
--[[
join
Join all non empty arguments together; the first argument is the separator.
Usage:
{{#invoke:String|join|sep|one|two|three}}
]]
function str.join(frame)
local args = {}
local sep
for _, v in ipairs( frame.args ) do
if sep then
if v ~= '' then
table.insert(args, v)
end
else
sep = v
end
end
return table.concat( args, sep or '' )
end
--[[
Helper function that populates the argument list given that user may need to use a mix of
named and unnamed parameters. This is relevant because named parameters are not
identical to unnamed parameters due to string trimming, and when dealing with strings
we sometimes want to either preserve or remove that whitespace depending on the application.
]]
function str._getParameters( frame_args, arg_list )
local new_args = {}
local index = 1
local value
for _, arg in ipairs( arg_list ) do
value = frame_args[arg]
if value == nil then
value = frame_args[index]
index = index + 1
end
new_args[arg] = value
end
return new_args
end
--[[
Helper function to handle error messages.
]]
function str._error( error_str )
local frame = mw.getCurrentFrame()
local error_category = frame.args.error_category or 'Errors reported by Module String'
local ignore_errors = frame.args.ignore_errors or false
local no_category = frame.args.no_category or false
if str._getBoolean(ignore_errors) then
return ''
end
local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>'
if error_category ~= '' and not str._getBoolean( no_category ) then
error_str = '[[Category:' .. error_category .. ']]' .. error_str
end
return error_str
end
--[[
Helper Function to interpret boolean strings
]]
function str._getBoolean( boolean_str )
local boolean_value
if type( boolean_str ) == 'string' then
boolean_str = boolean_str:lower()
if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0'
or boolean_str == '' then
boolean_value = false
else
boolean_value = true
end
elseif type( boolean_str ) == 'boolean' then
boolean_value = boolean_str
else
error( 'No boolean value found' )
end
return boolean_value
end
--[[
Helper function that escapes all pattern characters so that they will be treated
as plain text.
]]
function str._escapePattern( pattern_str )
return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" )
end
return str
6df794dd52434e0f6a372c9918f5a9dedd15f579
Template:Convert
10
93
189
2020-08-09T22:52:24Z
w>Bsherr
0
adding comment
wikitext
text/x-wiki
<includeonly>{{{{{♥|safesubst:}}}#invoke:convert|convert}}</includeonly><noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage, interwikis to Wikidata, not here -->
</noinclude>
952ac4080dc4a427c4a65db9951c8a4f4c91c626
Template:Yesno
10
13
29
2020-08-28T03:15:17Z
Template>Xaosflux
0
add additional paramerters, "t", "f" - requested on talk - worked in sandbox /testcases
wikitext
text/x-wiki
{{<includeonly>safesubst:</includeonly>#switch: {{<includeonly>safesubst:</includeonly>lc: {{{1|¬}}} }}
|no
|n
|f
|false
|off
|0 = {{{no|<!-- null -->}}}
| = {{{blank|{{{no|<!-- null -->}}}}}}
|¬ = {{{¬|}}}
|yes
|y
|t
|true
|on
|1 = {{{yes|yes}}}
|#default = {{{def|{{{yes|yes}}}}}}
}}<noinclude>
{{Documentation}}
</noinclude>
629c2937bc5cf7cfe13cd2a598582af832782399
Module:TNT
828
76
155
2020-08-30T07:28:25Z
Template>Johnuniq
0
Changed protection level for "[[Module:TNT]]": [[WP:High-risk templates|High-risk Lua module]]: per request at [[WP:RFPP]] to match [[Module:Excerpt]] ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
Scribunto
text/plain
--
-- INTRO: (!!! DO NOT RENAME THIS PAGE !!!)
-- This module allows any template or module to be copy/pasted between
-- wikis without any translation changes. All translation text is stored
-- in the global Data:*.tab pages on Commons, and used everywhere.
--
-- SEE: https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules
--
-- ATTENTION:
-- Please do NOT rename this module - it has to be identical on all wikis.
-- This code is maintained at https://www.mediawiki.org/wiki/Module:TNT
-- Please do not modify it anywhere else, as it may get copied and override your changes.
-- Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT
--
-- DESCRIPTION:
-- The "msg" function uses a Commons dataset to translate a message
-- with a given key (e.g. source-table), plus optional arguments
-- to the wiki markup in the current content language.
-- Use lang=xx to set language. Example:
--
-- {{#invoke:TNT | msg
-- | I18n/Template:Graphs.tab <!-- https://commons.wikimedia.org/wiki/Data:I18n/Template:Graphs.tab -->
-- | source-table <!-- uses a translation message with id = "source-table" -->
-- | param1 }} <!-- optional parameter -->
--
--
-- The "doc" function will generate the <templatedata> parameter documentation for templates.
-- This way all template parameters can be stored and localized in a single Commons dataset.
-- NOTE: "doc" assumes that all documentation is located in Data:Templatedata/* on Commons.
--
-- {{#invoke:TNT | doc | Graph:Lines }}
-- uses https://commons.wikimedia.org/wiki/Data:Templatedata/Graph:Lines.tab
-- if the current page is Template:Graph:Lines/doc
--
local p = {}
local i18nDataset = 'I18n/Module:TNT.tab'
-- Forward declaration of the local functions
local sanitizeDataset, loadData, link, formatMessage
function p.msg(frame)
local dataset, id
local params = {}
local lang = nil
for k, v in pairs(frame.args) do
if k == 1 then
dataset = mw.text.trim(v)
elseif k == 2 then
id = mw.text.trim(v)
elseif type(k) == 'number' then
table.insert(params, mw.text.trim(v))
elseif k == 'lang' and v ~= '_' then
lang = mw.text.trim(v)
end
end
return formatMessage(dataset, id, params, lang)
end
-- Identical to p.msg() above, but used from other lua modules
-- Parameters: name of dataset, message key, optional arguments
-- Example with 2 params: format('I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset')
function p.format(dataset, key, ...)
local checkType = require('libraryUtil').checkType
checkType('format', 1, dataset, 'string')
checkType('format', 2, key, 'string')
return formatMessage(dataset, key, {...})
end
-- Identical to p.msg() above, but used from other lua modules with the language param
-- Parameters: language code, name of dataset, message key, optional arguments
-- Example with 2 params: formatInLanguage('es', I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset')
function p.formatInLanguage(lang, dataset, key, ...)
local checkType = require('libraryUtil').checkType
checkType('formatInLanguage', 1, lang, 'string')
checkType('formatInLanguage', 2, dataset, 'string')
checkType('formatInLanguage', 3, key, 'string')
return formatMessage(dataset, key, {...}, lang)
end
-- Obsolete function that adds a 'c:' prefix to the first param.
-- "Sandbox/Sample.tab" -> 'c:Data:Sandbox/Sample.tab'
function p.link(frame)
return link(frame.args[1])
end
function p.doc(frame)
local dataset = 'Templatedata/' .. sanitizeDataset(frame.args[1])
return frame:extensionTag('templatedata', p.getTemplateData(dataset)) ..
formatMessage(i18nDataset, 'edit_doc', {link(dataset)})
end
function p.getTemplateData(dataset)
-- TODO: add '_' parameter once lua starts reindexing properly for "all" languages
local data = loadData(dataset)
local names = {}
for _, field in pairs(data.schema.fields) do
table.insert(names, field.name)
end
local params = {}
local paramOrder = {}
for _, row in pairs(data.data) do
local newVal = {}
local name = nil
for pos, val in pairs(row) do
local columnName = names[pos]
if columnName == 'name' then
name = val
else
newVal[columnName] = val
end
end
if name then
params[name] = newVal
table.insert(paramOrder, name)
end
end
-- Work around json encoding treating {"1":{...}} as an [{...}]
params['zzz123']=''
local json = mw.text.jsonEncode({
params=params,
paramOrder=paramOrder,
description=data.description
})
json = string.gsub(json,'"zzz123":"",?', "")
return json
end
-- Local functions
sanitizeDataset = function(dataset)
if not dataset then
return nil
end
dataset = mw.text.trim(dataset)
if dataset == '' then
return nil
elseif string.sub(dataset,-4) ~= '.tab' then
return dataset .. '.tab'
else
return dataset
end
end
loadData = function(dataset, lang)
dataset = sanitizeDataset(dataset)
if not dataset then
error(formatMessage(i18nDataset, 'error_no_dataset', {}))
end
-- Give helpful error to thirdparties who try and copy this module.
if not mw.ext or not mw.ext.data or not mw.ext.data.get then
error('Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:' .. dataset)
end
local data = mw.ext.data.get(dataset, lang)
if data == false then
if dataset == i18nDataset then
-- Prevent cyclical calls
error('Missing Commons dataset ' .. i18nDataset)
else
error(formatMessage(i18nDataset, 'error_bad_dataset', {link(dataset)}))
end
end
return data
end
-- Given a dataset name, convert it to a title with the 'commons:data:' prefix
link = function(dataset)
return 'c:Data:' .. mw.text.trim(dataset or '')
end
formatMessage = function(dataset, key, params, lang)
for _, row in pairs(loadData(dataset, lang).data) do
local id, msg = unpack(row)
if id == key then
local result = mw.message.newRawMessage(msg, unpack(params or {}))
return result:plain()
end
end
if dataset == i18nDataset then
-- Prevent cyclical calls
error('Invalid message key "' .. key .. '"')
else
error(formatMessage(i18nDataset, 'error_bad_msgkey', {key, link(dataset)}))
end
end
return p
9d0d10e54abd232c806dcabccaf03e52858634a1
Module:Effective protection level
828
31
65
2020-09-29T03:38:47Z
Template>Jackmcbarn
0
bring in changes from sandbox
Scribunto
text/plain
local p = {}
-- Returns the permission required to perform a given action on a given title.
-- If no title is specified, the title of the page being displayed is used.
function p._main(action, pagename)
local title
if type(pagename) == 'table' and pagename.prefixedText then
title = pagename
elseif pagename then
title = mw.title.new(pagename)
else
title = mw.title.getCurrentTitle()
end
pagename = title.prefixedText
if action == 'autoreview' then
local level = mw.ext.FlaggedRevs.getStabilitySettings(title)
level = level and level.autoreview
if level == 'review' then
return 'reviewer'
elseif level ~= '' then
return level
else
return nil -- not '*'. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not '', as that would mean PC-protected but nobody can review
end
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then
error( 'First parameter must be one of edit, move, create, upload, undelete, autoreview', 2 )
end
if title.namespace == 8 then -- MediaWiki namespace
if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page
return 'interfaceadmin'
else -- any non-JS/CSS MediaWiki page
return 'sysop'
end
elseif title.namespace == 2 and title.isSubpage then
if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page
return 'interfaceadmin'
elseif title.contentModel == 'json' then -- user JSON page
return 'sysop'
end
end
if action == 'undelete' then
return 'sysop'
end
local level = title.protectionLevels[action] and title.protectionLevels[action][1]
if level == 'sysop' or level == 'editprotected' then
return 'sysop'
elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page
return 'sysop'
elseif level == 'templateeditor' then
return 'templateeditor'
elseif action == 'move' then
local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move.
if blacklistentry and not blacklistentry.params.autoconfirmed then
return 'templateeditor'
elseif title.namespace == 6 then
return 'filemover'
elseif level == 'extendedconfirmed' then
return 'extendedconfirmed'
else
return 'autoconfirmed'
end
end
local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename)
if blacklistentry then
if not blacklistentry.params.autoconfirmed then
return 'templateeditor'
elseif level == 'extendedconfirmed' then
return 'extendedconfirmed'
else
return 'autoconfirmed'
end
elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason
return 'autoconfirmed'
elseif level then
return level
elseif action == 'upload' then
return 'autoconfirmed'
elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts
return 'user'
else
return '*'
end
end
setmetatable(p, { __index = function(t, k)
return function(frame)
return t._main(k, frame.args[1])
end
end })
return p
70256a489edf6be9808031b14a7e3ef3e025da97
Module:Documentation/styles.css
828
53
109
2020-11-19T20:21:58Z
Template>Izno
0
Changed protection level for "[[Module:Documentation/styles.css]]": actually match module ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
text
text/plain
/* {{pp|small=yes}} */
.documentation,
.documentation-metadata {
border: 1px solid #a2a9b1;
background-color: #ecfcf4;
clear: both;
}
.documentation {
margin: 1em 0 0 0;
padding: 1em;
}
.documentation-metadata {
margin: 0.2em 0; /* same margin left-right as .documentation */
font-style: italic;
padding: 0.4em 1em; /* same padding left-right as .documentation */
}
.documentation-startbox {
padding-bottom: 3px;
border-bottom: 1px solid #aaa;
margin-bottom: 1ex;
}
.documentation-heading {
font-weight: bold;
font-size: 125%;
}
.documentation-clear { /* Don't want things to stick out where they shouldn't. */
clear: both;
}
.documentation-toolbar {
font-style: normal;
font-size: 85%;
}
ce0e629c92e3d825ab9fd927fe6cc37d9117b6cb
Template:Tlxs
10
132
267
2020-11-20T18:15:40Z
w>Primefac
0
Primefac moved page [[Template:Tlxs]] to [[Template:Template link expanded with subst]]: make the name more obvious
wikitext
text/x-wiki
#REDIRECT [[Template:Template link expanded with subst]]
{{Redirect category shell|
{{R from move}}
}}
74e095f26cae0cd68518f2f66d74e948a7861c79
Template:Tlx
10
22
47
2020-11-20T18:53:35Z
Template>Primefac
0
Primefac moved page [[Template:Tlx]] to [[Template:Template link expanded]] over redirect: expand name, make it more obvious
wikitext
text/x-wiki
#REDIRECT [[Template:Template link expanded]]
{{Redirect category shell|
{{R from move}}
}}
1fec988ceb46cb324af228aac45d7cd25fcc9008
Template:Template link expanded
10
23
49
2020-11-21T12:04:41Z
Template>Primefac
0
update
wikitext
text/x-wiki
{{#Invoke:Template link general|main|code=on}}<noinclude>
{{Documentation|1=Template:Tlg/doc
|content = {{tlg/doc|tlx}}
}}
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
6c99696fee02f1da368ed20d2504e19bc15b1c13
Template:Template link with link off
10
56
115
2020-11-21T12:06:17Z
Template>Primefac
0
update
wikitext
text/x-wiki
<includeonly>{{#Invoke:Template link general|main|nowrap=yes|nolink=yes}}</includeonly><noinclude>
{{Documentation|1=Template:Tlg/doc
|content = {{tlg/doc|tlf}}
}}
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
b099fea5d1f36b0b4b9cb253ad3a9f4e095f6851
Template:Template link expanded with subst
10
133
269
2020-11-21T12:06:51Z
w>Primefac
0
update
wikitext
text/x-wiki
{{#Invoke:Template link general|main|code=on|subst=on}}<noinclude>
{{Documentation|1=Template:Tlg/doc
|content = {{tlg/doc|tlxs}}
}}
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
9b2ef0a8c882c336902f1d61dcff3658528c2210
Module:Data
828
98
199
2021-01-16T19:03:09Z
w>Jackmcbarn
0
Make this work when called with wikitext's fake tables
Scribunto
text/plain
local mt = {}
function mt.__index(t, k)
return function(frame)
local data = mw.loadData(k)
local i = 1
for _,v in ipairs(frame.args) do
local ty = type(data)
if ty ~= 'table' then
local args = {}
for j = 1, i - 1 do
args[j] = frame.args[j]
end
if frame.args.softfail then
return '<span class="error">[[Category:Pages with failed Module:Data lookups]]Error: Tried to read index "' .. mw.text.nowiki(v) .. '" of mw.loadData("' .. mw.text.nowiki(k) .. '").' .. mw.text.nowiki(table.concat(args, '.')) .. ', which is a ' .. ty .. '</span>'
else
error('Tried to read index "' .. v .. '" of mw.loadData("' .. k .. '").' .. table.concat(args, '.') .. ', which is a ' .. ty)
end
end
data = data[v]
i = i + 1
end
return data
end
end
return setmetatable({}, mt)
654c5ba2e0c73e7415457ca7a67fe0dfacfdba3b
Template:Tl
10
9
21
2021-02-12T22:03:00Z
Template>Anthony Appleyard
0
Anthony Appleyard moved page [[Template:Tl]] to [[Template:Template link]]: [[Special:Permalink/1006428669|Requested]] by Buidhe at [[WP:RM/TR]]: RM closed as move
wikitext
text/x-wiki
#REDIRECT [[Template:Template link]]
{{Redirect category shell|
{{R from move}}
}}
d6593bb3b4a866249f55d0f34b047a71fe1f1529
Template:Div col
10
45
93
2021-02-14T23:20:57Z
Template>Matt Fitzpatrick
0
whitelist parameter class
wikitext
text/x-wiki
<includeonly><templatestyles src="Div col/styles.css"/><!--
--><div class="div-col {{#ifeq:{{{small|}}}|yes|div-col-small}} {{#ifeq:{{{rules|}}}|yes|div-col-rules}} {{{class|}}}" <!--
-->{{#if:{{{colwidth|}}}{{{gap|}}}{{{style|}}}|<!--
-->style="{{#if:{{{colwidth|}}}|column-width: {{{colwidth}}};}}{{#if:{{{gap|}}}|column-gap: {{{gap}}};}}{{#if:{{{style|}}}|{{{style}}}}}"<!--
-->}}><!--
-->{{#if:{{{content|}}}|{{{content}}}</div>}}<!-- Inventory how many pages use small=yes
-->{{#ifeq:{{{small|}}}|yes|[[Category:Pages using div col with small parameter]]}}<!--
--></includeonly>{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using div col with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Div col]] with unknown parameter "_VALUE_"; use colwidth= to specify column size |ignoreblank=y | class | colwidth | content | gap | rules | small | style }}<noinclude>
{{Documentation}}
</noinclude>
6e84133dd867d6c701e7b161878cf66665bb7eb7
Template:Template shortcut
10
138
279
2021-02-16T17:54:32Z
w>Nardog
0
TfM closed as convert
wikitext
text/x-wiki
<includeonly>{{#invoke:Shortcut|main|template=yes}}</includeonly><noinclude>{{Documentation}}</noinclude>
bfb2889c4c0ec36294b7b667f5e03350d2df680e
Module:Shortcut/config
828
135
273
2021-02-16T18:43:45Z
w>Nardog
0
Scribunto
text/plain
-- This module holds configuration data for [[Module:Shortcut]].
return {
-- The heading at the top of the shortcut box. It accepts the following parameter:
-- $1 - the total number of shortcuts. (required)
['shortcut-heading'] = '[[Wikipedia:Shortcut|{{PLURAL:$1|Shortcut|Shortcuts}}]]',
-- The heading when |redirect=yes is given. It accepts the following parameter:
-- $1 - the total number of shortcuts. (required)
['redirect-heading'] = '[[Wikipedia:Redirect|{{PLURAL:$1|Redirect|Redirects}}]]',
-- The error message to display when a shortcut is invalid (is not a string, or
-- is the blank string). It accepts the following parameter:
-- $1 - the number of the shortcut in the argument list. (required)
['invalid-shortcut-error'] = 'shortcut #$1 was invalid (shortcuts must be ' ..
'strings of at least one character in length)',
-- The error message to display when no shortcuts or other displayable content
-- were specified. (required)
['no-content-error'] = 'Error: no shortcuts were specified and the ' ..
mw.text.nowiki('|msg=') ..
' parameter was not set.',
-- A category to add when the no-content-error message is displayed. (optional)
['no-content-error-category'] = 'Shortcut templates with missing parameters',
}
f9d1d94844d5953753eb19e30a3ce389eda3d319
Module:Math
828
146
295
2021-03-11T22:23:48Z
w>Primefac
0
typo fix
Scribunto
text/plain
--[[
This module provides a number of basic mathematical operations.
]]
local yesno, getArgs -- lazily initialized
local p = {} -- Holds functions to be returned from #invoke, and functions to make available to other Lua modules.
local wrap = {} -- Holds wrapper functions that process arguments from #invoke. These act as intemediary between functions meant for #invoke and functions meant for Lua.
--[[
Helper functions used to avoid redundant code.
]]
local function err(msg)
-- Generates wikitext error messages.
return mw.ustring.format('<strong class="error">Formatting error: %s</strong>', msg)
end
local function unpackNumberArgs(args)
-- Returns an unpacked list of arguments specified with numerical keys.
local ret = {}
for k, v in pairs(args) do
if type(k) == 'number' then
table.insert(ret, v)
end
end
return unpack(ret)
end
local function makeArgArray(...)
-- Makes an array of arguments from a list of arguments that might include nils.
local args = {...} -- Table of arguments. It might contain nils or non-number values, so we can't use ipairs.
local nums = {} -- Stores the numbers of valid numerical arguments.
local ret = {}
for k, v in pairs(args) do
v = p._cleanNumber(v)
if v then
nums[#nums + 1] = k
args[k] = v
end
end
table.sort(nums)
for i, num in ipairs(nums) do
ret[#ret + 1] = args[num]
end
return ret
end
local function fold(func, ...)
-- Use a function on all supplied arguments, and return the result. The function must accept two numbers as parameters,
-- and must return a number as an output. This number is then supplied as input to the next function call.
local vals = makeArgArray(...)
local count = #vals -- The number of valid arguments
if count == 0 then return
-- Exit if we have no valid args, otherwise removing the first arg would cause an error.
nil, 0
end
local ret = table.remove(vals, 1)
for _, val in ipairs(vals) do
ret = func(ret, val)
end
return ret, count
end
--[[
Fold arguments by selectively choosing values (func should return when to choose the current "dominant" value).
]]
local function binary_fold(func, ...)
local value = fold((function(a, b) if func(a, b) then return a else return b end end), ...)
return value
end
--[[
random
Generate a random number
Usage:
{{#invoke: Math | random }}
{{#invoke: Math | random | maximum value }}
{{#invoke: Math | random | minimum value | maximum value }}
]]
function wrap.random(args)
local first = p._cleanNumber(args[1])
local second = p._cleanNumber(args[2])
return p._random(first, second)
end
function p._random(first, second)
math.randomseed(mw.site.stats.edits + mw.site.stats.pages + os.time() + math.floor(os.clock() * 1000000000))
-- math.random will throw an error if given an explicit nil parameter, so we need to use if statements to check the params.
if first and second then
if first <= second then -- math.random doesn't allow the first number to be greater than the second.
return math.random(first, second)
end
elseif first then
return math.random(first)
else
return math.random()
end
end
--[[
order
Determine order of magnitude of a number
Usage:
{{#invoke: Math | order | value }}
]]
function wrap.order(args)
local input_string = (args[1] or args.x or '0');
local input_number = p._cleanNumber(input_string);
if input_number == nil then
return err('order of magnitude input appears non-numeric')
else
return p._order(input_number)
end
end
function p._order(x)
if x == 0 then return 0 end
return math.floor(math.log10(math.abs(x)))
end
--[[
precision
Detemines the precision of a number using the string representation
Usage:
{{ #invoke: Math | precision | value }}
]]
function wrap.precision(args)
local input_string = (args[1] or args.x or '0');
local trap_fraction = args.check_fraction;
local input_number;
if not yesno then
yesno = require('Module:Yesno')
end
if yesno(trap_fraction, true) then -- Returns true for all input except nil, false, "no", "n", "0" and a few others. See [[Module:Yesno]].
local pos = string.find(input_string, '/', 1, true);
if pos ~= nil then
if string.find(input_string, '/', pos + 1, true) == nil then
local denominator = string.sub(input_string, pos+1, -1);
local denom_value = tonumber(denominator);
if denom_value ~= nil then
return math.log10(denom_value);
end
end
end
end
input_number, input_string = p._cleanNumber(input_string);
if input_string == nil then
return err('precision input appears non-numeric')
else
return p._precision(input_string)
end
end
function p._precision(x)
if type(x) == 'number' then
x = tostring(x)
end
x = string.upper(x)
local decimal = x:find('%.')
local exponent_pos = x:find('E')
local result = 0;
if exponent_pos ~= nil then
local exponent = string.sub(x, exponent_pos + 1)
x = string.sub(x, 1, exponent_pos - 1)
result = result - tonumber(exponent)
end
if decimal ~= nil then
result = result + string.len(x) - decimal
return result
end
local pos = string.len(x);
while x:byte(pos) == string.byte('0') do
pos = pos - 1
result = result - 1
if pos <= 0 then
return 0
end
end
return result
end
--[[
max
Finds the maximum argument
Usage:
{{#invoke:Math| max | value1 | value2 | ... }}
Note, any values that do not evaluate to numbers are ignored.
]]
function wrap.max(args)
return p._max(unpackNumberArgs(args))
end
function p._max(...)
local max_value = binary_fold((function(a, b) return a > b end), ...)
if max_value then
return max_value
end
end
--[[
median
Find the median of set of numbers
Usage:
{{#invoke:Math | median | number1 | number2 | ...}}
OR
{{#invoke:Math | median }}
]]
function wrap.median(args)
return p._median(unpackNumberArgs(args))
end
function p._median(...)
local vals = makeArgArray(...)
local count = #vals
table.sort(vals)
if count == 0 then
return 0
end
if p._mod(count, 2) == 0 then
return (vals[count/2] + vals[count/2+1])/2
else
return vals[math.ceil(count/2)]
end
end
--[[
min
Finds the minimum argument
Usage:
{{#invoke:Math| min | value1 | value2 | ... }}
OR
{{#invoke:Math| min }}
When used with no arguments, it takes its input from the parent
frame. Note, any values that do not evaluate to numbers are ignored.
]]
function wrap.min(args)
return p._min(unpackNumberArgs(args))
end
function p._min(...)
local min_value = binary_fold((function(a, b) return a < b end), ...)
if min_value then
return min_value
end
end
--[[
sum
Finds the sum
Usage:
{{#invoke:Math| sum | value1 | value2 | ... }}
OR
{{#invoke:Math| sum }}
Note, any values that do not evaluate to numbers are ignored.
]]
function wrap.sum(args)
return p._sum(unpackNumberArgs(args))
end
function p._sum(...)
local sums, count = fold((function(a, b) return a + b end), ...)
if not sums then
return 0
else
return sums
end
end
--[[
average
Finds the average
Usage:
{{#invoke:Math| average | value1 | value2 | ... }}
OR
{{#invoke:Math| average }}
Note, any values that do not evaluate to numbers are ignored.
]]
function wrap.average(args)
return p._average(unpackNumberArgs(args))
end
function p._average(...)
local sum, count = fold((function(a, b) return a + b end), ...)
if not sum then
return 0
else
return sum / count
end
end
--[[
round
Rounds a number to specified precision
Usage:
{{#invoke:Math | round | value | precision }}
--]]
function wrap.round(args)
local value = p._cleanNumber(args[1] or args.value or 0)
local precision = p._cleanNumber(args[2] or args.precision or 0)
if value == nil or precision == nil then
return err('round input appears non-numeric')
else
return p._round(value, precision)
end
end
function p._round(value, precision)
local rescale = math.pow(10, precision or 0);
return math.floor(value * rescale + 0.5) / rescale;
end
--[[
log10
returns the log (base 10) of a number
Usage:
{{#invoke:Math | log10 | x }}
]]
function wrap.log10(args)
return math.log10(args[1])
end
--[[
mod
Implements the modulo operator
Usage:
{{#invoke:Math | mod | x | y }}
--]]
function wrap.mod(args)
local x = p._cleanNumber(args[1])
local y = p._cleanNumber(args[2])
if not x then
return err('first argument to mod appears non-numeric')
elseif not y then
return err('second argument to mod appears non-numeric')
else
return p._mod(x, y)
end
end
function p._mod(x, y)
local ret = x % y
if not (0 <= ret and ret < y) then
ret = 0
end
return ret
end
--[[
gcd
Calculates the greatest common divisor of multiple numbers
Usage:
{{#invoke:Math | gcd | value 1 | value 2 | value 3 | ... }}
--]]
function wrap.gcd(args)
return p._gcd(unpackNumberArgs(args))
end
function p._gcd(...)
local function findGcd(a, b)
local r = b
local oldr = a
while r ~= 0 do
local quotient = math.floor(oldr / r)
oldr, r = r, oldr - quotient * r
end
if oldr < 0 then
oldr = oldr * -1
end
return oldr
end
local result, count = fold(findGcd, ...)
return result
end
--[[
precision_format
Rounds a number to the specified precision and formats according to rules
originally used for {{template:Rnd}}. Output is a string.
Usage:
{{#invoke: Math | precision_format | number | precision }}
]]
function wrap.precision_format(args)
local value_string = args[1] or 0
local precision = args[2] or 0
return p._precision_format(value_string, precision)
end
function p._precision_format(value_string, precision)
-- For access to Mediawiki built-in formatter.
local lang = mw.getContentLanguage();
local value
value, value_string = p._cleanNumber(value_string)
precision = p._cleanNumber(precision)
-- Check for non-numeric input
if value == nil or precision == nil then
return err('invalid input when rounding')
end
local current_precision = p._precision(value)
local order = p._order(value)
-- Due to round-off effects it is neccesary to limit the returned precision under
-- some circumstances because the terminal digits will be inaccurately reported.
if order + precision >= 14 then
if order + p._precision(value_string) >= 14 then
precision = 13 - order;
end
end
-- If rounding off, truncate extra digits
if precision < current_precision then
value = p._round(value, precision)
current_precision = p._precision(value)
end
local formatted_num = lang:formatNum(math.abs(value))
local sign
-- Use proper unary minus sign rather than ASCII default
if value < 0 then
sign = '−'
else
sign = ''
end
-- Handle cases requiring scientific notation
if string.find(formatted_num, 'E', 1, true) ~= nil or math.abs(order) >= 9 then
value = value * math.pow(10, -order)
current_precision = current_precision + order
precision = precision + order
formatted_num = lang:formatNum(math.abs(value))
else
order = 0;
end
formatted_num = sign .. formatted_num
-- Pad with zeros, if needed
if current_precision < precision then
local padding
if current_precision <= 0 then
if precision > 0 then
local zero_sep = lang:formatNum(1.1)
formatted_num = formatted_num .. zero_sep:sub(2,2)
padding = precision
if padding > 20 then
padding = 20
end
formatted_num = formatted_num .. string.rep('0', padding)
end
else
padding = precision - current_precision
if padding > 20 then
padding = 20
end
formatted_num = formatted_num .. string.rep('0', padding)
end
end
-- Add exponential notation, if necessary.
if order ~= 0 then
-- Use proper unary minus sign rather than ASCII default
if order < 0 then
order = '−' .. lang:formatNum(math.abs(order))
else
order = lang:formatNum(order)
end
formatted_num = formatted_num .. '<span style="margin:0 .15em 0 .25em">×</span>10<sup>' .. order .. '</sup>'
end
return formatted_num
end
--[[
divide
Implements the division operator
Usage:
{{#invoke:Math | divide | x | y | round= | precision= }}
--]]
function wrap.divide(args)
local x = args[1]
local y = args[2]
local round = args.round
local precision = args.precision
if not yesno then
yesno = require('Module:Yesno')
end
return p._divide(x, y, yesno(round), precision)
end
function p._divide(x, y, round, precision)
if y == nil or y == "" then
return err("Empty divisor")
elseif not tonumber(y) then
if type(y) == 'string' and string.sub(y, 1, 1) == '<' then
return y
else
return err("Not a number: " .. y)
end
elseif x == nil or x == "" then
return err("Empty dividend")
elseif not tonumber(x) then
if type(x) == 'string' and string.sub(x, 1, 1) == '<' then
return x
else
return err("Not a number: " .. x)
end
else
local z = x / y
if round then
return p._round(z, 0)
elseif precision then
return p._round(z, precision)
else
return z
end
end
end
--[[
Helper function that interprets the input numerically. If the
input does not appear to be a number, attempts evaluating it as
a parser functions expression.
]]
function p._cleanNumber(number_string)
if type(number_string) == 'number' then
-- We were passed a number, so we don't need to do any processing.
return number_string, tostring(number_string)
elseif type(number_string) ~= 'string' or not number_string:find('%S') then
-- We were passed a non-string or a blank string, so exit.
return nil, nil;
end
-- Attempt basic conversion
local number = tonumber(number_string)
-- If failed, attempt to evaluate input as an expression
if number == nil then
local success, result = pcall(mw.ext.ParserFunctions.expr, number_string)
if success then
number = tonumber(result)
number_string = tostring(number)
else
number = nil
number_string = nil
end
else
number_string = number_string:match("^%s*(.-)%s*$") -- String is valid but may contain padding, clean it.
number_string = number_string:match("^%+(.*)$") or number_string -- Trim any leading + signs.
if number_string:find('^%-?0[xX]') then
-- Number is using 0xnnn notation to indicate base 16; use the number that Lua detected instead.
number_string = tostring(number)
end
end
return number, number_string
end
--[[
Wrapper function that does basic argument processing. This ensures that all functions from #invoke can use either the current
frame or the parent frame, and it also trims whitespace for all arguments and removes blank arguments.
]]
local mt = { __index = function(t, k)
return function(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
return wrap[k](getArgs(frame)) -- Argument processing is left to Module:Arguments. Whitespace is trimmed and blank arguments are removed.
end
end }
return setmetatable(p, mt)
2bbe734d898299f65412963a3c1782e9fcc4d9ca
Template:Template link
10
10
23
2021-03-25T19:03:22Z
Template>Izno
0
[[Wikipedia:Templates for discussion/Log/2021 March 18#Template:Tlu]] closed as keep ([[WP:XFDC#4.0.11|XFDcloser]])
wikitext
text/x-wiki
{{[[Template:{{{1}}}|{{{1}}}]]}}<noinclude>{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
eabbec62efe3044a98ebb3ce9e7d4d43c222351d
Template:Category link with count
10
67
137
2021-06-11T18:13:44Z
Template>GKFX
0
Support wider range of (valid) input format
wikitext
text/x-wiki
[[:Category:{{#invoke:string|replace|1={{{1}}}|2=^:?[Cc]ategory:|3=|plain=false}}|<!--
-->{{#if:{{{name|}}}|{{{name}}}|Category:{{#invoke:string|replace|1={{{1}}}|2=^:?[Cc]ategory:|3=|plain=false}}}}<!--
-->]] ({{PAGESINCATEGORY:{{#invoke:string|replace|1={{{1}}}|2=^:?[Cc]ategory:|3=|plain=false}}|{{{2|all}}}}})<noinclude>
{{Documentation}}
</noinclude>
f93f1540b8c157703bd6d24ae35c35bef745981d
Template:Infobox ship image/doc
10
121
245
2021-06-20T15:24:43Z
w>1234qwer1234qwer4
0
/* top */{{Documentation subpage}}
wikitext
text/x-wiki
{{Documentation subpage}}
{{Lua|Module:InfoboxImage|Module:Check for unknown parameters}}
This template is part of the new WikiProject Ships ship infobox. It adds a picture and caption to the infobox. Each section, except Infobox Ship Begin, can be repeated as necessary to support multiple careers, multiple sets of characteristics, etc.
{{Infobox ship begin/shared doc}}
===TemplateData===
{{TemplateData header}}
<templatedata>
{
"description": "Used to add an image to ship articles. Used with {{Infobox ship begin}}. If your article does not have an image in this field, the ship will automatically be listed at the hidden category [[Category:Ship infoboxes without an image]]. Editors can use the category to easily see a list of infoboxes where no image is attached and work to find pictures.",
"paramOrder": [
"image",
"image alt",
"image size",
"caption"
],
"params": {
"image": {
"aliases": [
"Ship image"
],
"label": "Image name",
"type": "string",
"required": true,
"description": "Name of the image to be displayed. Simple name is enough. Full image syntax is accepted... for now."
},
"image size": {
"aliases": [
"Ship image size"
],
"label": "Image size",
"type": "string",
"description": "Size of the image in CSS syntax. e.g. 300px. Optional. Use wisely; Wikipedia policy requires deviations from standard size to remain minimum. Ignored if a full image syntax with size is added to |image parameter.",
"default": "300px"
},
"image alt": {
"label": "Image alternative text",
"type": "string",
"description": "Alternative text for the image, shown to those who are unable to see the image."
},
"caption": {
"aliases": [
"Ship caption"
],
"label": "Caption",
"type": "string",
"description": "caption text shown beneath the image."
}
},
"format": "block"
}
</templatedata>
<includeonly>
[[tl:Suleras:Infobox Ship Image]]
[[tr:Şablon:Gemi bilgi kutusu resim]]
</includeonly>
e124f05235bce2d6d1b386a0b287764eb16fca24
Template:Infobox ship characteristics/doc
10
122
247
2021-06-23T15:35:06Z
w>Trappist the monk
0
+lua;
wikitext
text/x-wiki
{{Documentation subpage}}
{{lua|Module:WPSHIPS utilities}}
This template is part of the WikiProject Ships ship infobox. It adds a Characteristics section to the infobox. Each section, except Infobox Ship Begin, can be repeated as necessary to support multiple careers, multiple sets of characteristics, etc. The header of the Characteristics box can be hidden by setting its "Hide header=yes". This allows you to repeat certain fields by adding a second Characteristics box with a hidden header. Also, additional text can be added to the Characteristics box with "Header caption=".
{{Infobox ship begin/shared doc}}
===TemplateData===
{{TemplateData header}}
<templatedata>
{
"description": "Ship characteristics, to be used with {{Infobox ship begin}}",
"params": {
"Hide header": {
"label": "Hide header",
"type": "string",
"required": false
},
"Header caption": {
"label": "Header caption",
"type": "string",
"required": false
},
"Ship class": {
"label": "Ship class",
"type": "string",
"required": false
},
"Ship type": {
"label": "Ship type",
"type": "string",
"required": false
},
"Ship tonnage": {
"label": "Ship tonnage",
"type": "string",
"required": false
},
"Ship displacement": {
"label": "Ship displacement",
"type": "string",
"required": false
},
"Ship tons burthen": {
"label": "Ship tons burthen",
"type": "string",
"required": false
},
"Ship length": {
"label": "Ship length",
"type": "string",
"required": false
},
"Ship beam": {
"label": "Ship beam",
"type": "string",
"required": false
},
"Ship height": {
"label": "Ship height",
"type": "string",
"required": false
},
"Ship draught": {
"label": "Ship draught",
"type": "string",
"required": false
},
"Ship draft": {
"label": "Ship draft",
"type": "string",
"required": false
},
"Ship depth": {
"label": "Ship depth",
"type": "string",
"required": false
},
"Ship hold depth": {
"label": "Ship hold depth",
"type": "string",
"required": false
},
"Ship decks": {
"label": "Ship decks",
"type": "string",
"required": false
},
"Ship deck clearance": {
"label": "Ship deck clearance",
"type": "string",
"required": false
},
"Ship ramps": {
"label": "Ship ramps",
"type": "string",
"required": false
},
"Ship ice class": {
"label": "Ship ice class",
"type": "string",
"required": false
},
"Ship power": {
"label": "Ship power",
"type": "string",
"required": false
},
"Ship propulsion": {
"label": "Ship propulsion",
"type": "string",
"required": false
},
"Ship sail plan": {
"label": "Ship sail plan",
"type": "string",
"required": false
},
"Ship speed": {
"label": "Ship speed",
"type": "string",
"required": false
},
"Ship range": {
"label": "Ship range",
"type": "string",
"required": false
},
"Ship endurance": {
"label": "Ship endurance",
"type": "string",
"required": false
},
"Ship test depth": {
"label": "Ship test depth",
"type": "string",
"required": false
},
"Ship boats": {
"label": "Ship boats",
"type": "string",
"required": false
},
"Ship capacity": {
"label": "Ship capacity",
"type": "string",
"required": false
},
"Ship troops": {
"label": "Ship troops",
"type": "string",
"required": false
},
"Ship complement": {
"label": "Ship complement",
"type": "string",
"required": false
},
"Ship crew": {
"label": "Ship crew",
"type": "string",
"required": false
},
"Ship time to activate": {
"label": "Ship time to activate",
"type": "string",
"required": false
},
"Ship sensors": {
"label": "Ship sensors",
"type": "string",
"required": false
},
"Ship EW": {
"label": "Ship EW",
"type": "string",
"required": false
},
"Ship armament": {
"label": "Ship armament",
"type": "string",
"required": false
},
"Ship armour": {
"label": "Ship armour",
"type": "string",
"required": false
},
"Ship armor": {
"label": "Ship armor",
"type": "string",
"required": false
},
"Ship aircraft": {
"label": "Ship aircraft",
"type": "string",
"required": false
},
"Ship aircraft facilities": {
"label": "Ship aircraft facilities",
"type": "string",
"required": false
},
"Ship motto": {
"label": "Ship motto",
"type": "string",
"required": false
},
"Ship nickname": {
"label": "Ship nickname",
"type": "string",
"required": false
},
"Ship honours": {
"label": "Ship honours",
"type": "string",
"required": false
},
"Ship honors": {
"label": "Ship honors",
"type": "string",
"required": false
},
"Ship notes": {
"label": "Ship notes",
"type": "string",
"required": false
},
"Ship badge": {
"label": "Ship badge",
"type": "string",
"required": false
}
},
"format": "block"
}
</templatedata>
<includeonly>
[[tr:Şablon:Gemi bilgi kutusu karakteristik]]
</includeonly>
49163fbd152574ea5450b24d9e543721bea2ddd1
Template:Auto italic title
10
119
241
2021-06-24T20:04:36Z
w>Gonnym
0
wikitext
text/x-wiki
{{ombox
| type = notice
| text = This {{{2|infobox}}} should [[Wikipedia:Article titles#Italics and other formatting|italicize the article title]] automatically. If this is not required, add {{para|{{#if:{{{1|}}}|{{{1}}}|italic title}}|{{#if:{{{3|}}}|{{{3}}}|no}}}} to the list of parameters. {{#if: {{{short|}}} | | If this is required but the title is not being italicized, try {{para|{{#if:{{{1|}}}|{{{1}}}|italic title}}|force}}.}}
}}<noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage, interwikis to Wikidata, not here -->
</noinclude>
6dc78a3d3de470bea8dc684b3278f5806fe0f5c3
Module:Hatnote/styles.css
828
35
73
2021-07-12T19:22:27Z
Template>Izno
0
per my talk page
text
text/plain
/* {{pp|small=y}} */
.hatnote {
font-style: italic;
}
/* Limit structure CSS to divs because of [[Module:Hatnote inline]] */
div.hatnote {
/* @noflip */
padding-left: 1.6em;
margin-bottom: 0.5em;
}
.hatnote i {
font-style: normal;
}
/* The templatestyles element inserts a link element before hatnotes.
* TODO: Remove link if/when WMF resolves T200206 */
.hatnote + link + .hatnote {
margin-top: -0.5em;
}
44680ffd6e888866df2cdfa0341af9c7b97da94c
Template:TemplateData header
10
59
121
2021-08-29T21:32:29Z
Template>SUM1
0
Added "based" parameter to other transclusion
wikitext
text/x-wiki
<div class="templatedata-header">{{#if:{{{noheader|}}}|<!--
noheader:
-->{{Template parameter usage|based=y}}|<!--
+header:
-->This is the {{#if:{{{nolink|}}}|<!--
+header, nolink TD
-->TemplateData|<!--
+header, +link [[TD]]; DEFAULT:
-->[[Wikipedia:TemplateData|TemplateData]]}}<!--
e.o. #if:nolink; DEFAULT:
--> for this template used by [[mw:Extension:TemplateWizard|TemplateWizard]], [[Wikipedia:VisualEditor|VisualEditor]] and other tools. {{Template parameter usage|based=y}}<!--
e.o. #if:noheader
-->}}
'''TemplateData for {{{1|{{BASEPAGENAME}}}}}'''
</div><includeonly><!--
check parameters
-->{{#invoke:Check for unknown parameters|check
|unknown={{template other|1=[[Category:Pages using TemplateData header with unknown parameters|_VALUE_]]}}
|template=Template:TemplateData header
|1 |nolink |noheader
|preview=<div class="error" style="font-weight:normal">Unknown parameter '_VALUE_' in [[Template:TemplateData header]].</div>
}}<!--
-->{{template other|{{sandbox other||
[[Category:Templates using TemplateData]]
}}}}</includeonly><!--
--><noinclude>{{Documentation}}</noinclude>
ddfbb4ae793846b96d4c06330417fa6ed4da2adc
Module:Redirect
828
125
253
2021-09-10T07:46:37Z
w>Johnuniq
0
restore p.getTargetFromText which is used by [[Module:RfD]] which is causing "Lua error in Module:RfD at line 87: attempt to call upvalue 'getTargetFromText' (a nil value)"
Scribunto
text/plain
-- This module provides functions for getting the target of a redirect page.
local p = {}
-- Gets a mw.title object, using pcall to avoid generating script errors if we
-- are over the expensive function count limit (among other possible causes).
local function getTitle(...)
local success, titleObj = pcall(mw.title.new, ...)
if success then
return titleObj
else
return nil
end
end
-- Gets the name of a page that a redirect leads to, or nil if it isn't a
-- redirect.
function p.getTargetFromText(text)
local target = string.match(
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)%]%]"
) or string.match(
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)|[^%[%]]-%]%]"
)
return target and mw.uri.decode(target, 'PATH')
end
-- Gets the target of a redirect. If the page specified is not a redirect,
-- returns nil.
function p.getTarget(page, fulltext)
-- Get the title object. Both page names and title objects are allowed
-- as input.
local titleObj
if type(page) == 'string' or type(page) == 'number' then
titleObj = getTitle(page)
elseif type(page) == 'table' and type(page.getContent) == 'function' then
titleObj = page
else
error(string.format(
"bad argument #1 to 'getTarget'"
.. " (string, number, or title object expected, got %s)",
type(page)
), 2)
end
if not titleObj then
return nil
end
local targetTitle = titleObj.redirectTarget
if targetTitle then
if fulltext then
return targetTitle.fullText
else
return targetTitle.prefixedText
end
else
return nil
end
end
--[[
-- Given a single page name determines what page it redirects to and returns the
-- target page name, or the passed page name when not a redirect. The passed
-- page name can be given as plain text or as a page link.
--
-- Returns page name as plain text, or when the bracket parameter is given, as a
-- page link. Returns an error message when page does not exist or the redirect
-- target cannot be determined for some reason.
--]]
function p.luaMain(rname, bracket, fulltext)
if type(rname) ~= "string" or not rname:find("%S") then
return nil
end
bracket = bracket and "[[%s]]" or "%s"
rname = rname:match("%[%[(.+)%]%]") or rname
local target = p.getTarget(rname, fulltext)
local ret = target or rname
ret = getTitle(ret)
if ret then
if fulltext then
ret = ret.fullText
else
ret = ret.prefixedText
end
return bracket:format(ret)
else
return nil
end
end
-- Provides access to the luaMain function from wikitext.
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})
return p.luaMain(args[1], args.bracket, args.fulltext) or ''
end
-- Returns true if the specified page is a redirect, and false otherwise.
function p.luaIsRedirect(page)
local titleObj = getTitle(page)
if not titleObj then
return false
end
if titleObj.isRedirect then
return true
else
return false
end
end
-- Provides access to the luaIsRedirect function from wikitext, returning 'yes'
-- if the specified page is a redirect, and the blank string otherwise.
function p.isRedirect(frame)
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})
if p.luaIsRedirect(args[1]) then
return 'yes'
else
return ''
end
end
return p
a224c45940343d66f49a78b0a39b2045e2c45d20
Module:Sidebar/styles.css
828
44
91
2021-09-20T01:15:45Z
Template>Goszei
0
self-rv, it's a little tight
text
text/plain
/* {{pp-template}} */
/* TODO: Invert width design to be "mobile first" */
.sidebar {
/* TODO: Ask if we should have max-width 22em instead */
width: 22em;
/* @noflip */
float: right;
/* @noflip */
clear: right;
/* @noflip */
margin: 0.5em 0 1em 1em;
background: #f8f9fa;
border: 1px solid #aaa;
padding: 0.2em;
text-align: center;
line-height: 1.4em;
font-size: 88%;
border-collapse: collapse;
/* Timeless has display: none on .nomobile at mobile resolutions, so we
* unhide it with display: table and let precedence and proximity win.
*/
display: table;
}
/* Unfortunately, so does Minerva desktop, except Minerva drops an
* !important on the declaration. So we have to be mean for Minerva users.
* Mobile removes the element entirely with `wgMFRemovableClasses` in
* https://github.com/wikimedia/operations-mediawiki-config/blob/master/
wmf-config/InitialiseSettings.php#L16992
* which is why displaying it categorically with display: table works.
* We don't really want to expose the generic user in the wild on mobile to have
* to deal with sidebars. (Maybe the ones with collapsible lists, so that
* might be an improvement. That is blocked on [[:phab:T111565]].)
*/
body.skin-minerva .sidebar {
display: table !important;
/* also, minerva is way too aggressive about other stylings on tables.
* TODO remove when this template gets moved to a div. plans on talk page.
* We always float right on Minerva because that's a lot of extra CSS
* otherwise. */
float: right !important;
margin: 0.5em 0 1em 1em !important;
}
.sidebar-subgroup {
width: 100%;
margin: 0;
border-spacing: 0;
}
.sidebar-left {
/* @noflip */
float: left;
/* @noflip */
clear: left;
/* @noflip */
margin: 0.5em 1em 1em 0;
}
.sidebar-none {
float: none;
clear: both;
/* @noflip */
margin: 0.5em 1em 1em 0;
}
.sidebar-outer-title {
padding: 0 0.4em 0.2em;
font-size: 125%;
line-height: 1.2em;
font-weight: bold;
}
.sidebar-top-image {
padding: 0.4em;
}
.sidebar-top-caption,
.sidebar-pretitle-with-top-image,
.sidebar-caption {
padding: 0.2em 0.4em 0;
line-height: 1.2em;
}
.sidebar-pretitle {
padding: 0.4em 0.4em 0;
line-height: 1.2em;
}
.sidebar-title,
.sidebar-title-with-pretitle {
padding: 0.2em 0.8em;
font-size: 145%;
line-height: 1.2em;
}
.sidebar-title-with-pretitle {
padding: 0.1em 0.4em;
}
.sidebar-image {
padding: 0.2em 0.4em 0.4em;
}
.sidebar-heading {
padding: 0.1em 0.4em;
}
.sidebar-content {
padding: 0 0.5em 0.4em;
}
.sidebar-content-with-subgroup {
padding: 0.1em 0.4em 0.2em;
}
.sidebar-above,
.sidebar-below {
padding: 0.3em 0.8em;
font-weight: bold;
}
.sidebar-collapse .sidebar-above,
.sidebar-collapse .sidebar-below {
border-top: 1px solid #aaa;
border-bottom: 1px solid #aaa;
}
.sidebar-navbar {
text-align: right;
font-size: 115%;
padding: 0 0.4em 0.4em;
}
.sidebar-list-title {
padding: 0 0.4em;
text-align: left;
font-weight: bold;
line-height: 1.6em;
font-size: 105%;
}
/* centered text with mw-collapsible headers is finicky */
.sidebar-list-title-c {
padding: 0 0.4em;
text-align: center;
margin: 0 3.3em;
}
@media (max-width: 720px) {
/* users have wide latitude to set arbitrary width and margin :(
"Super-specific" selector to prevent overriding this appearance by
lower level sidebars too */
body.mediawiki .sidebar {
width: 100% !important;
clear: both;
float: none !important; /* Remove when we div based; Minerva is dumb */
margin-left: 0 !important;
margin-right: 0 !important;
}
/* TODO: We might consider making all links wrap at small resolutions and then
* only introduce nowrap at higher resolutions. Do when we invert the media
* query.
*/
}
7d621b35a37807a103b59075851fe36201204ceb
Module:Unsubst
828
126
255
2021-10-08T18:22:16Z
w>Trappist the monk
0
sync from sandbox; see [[Module_talk:Unsubst#template_invocation_name_override|talk]];
Scribunto
text/plain
local checkType = require('libraryUtil').checkType
local p = {}
local BODY_PARAM = '$B'
local specialParams = {
['$params'] = 'parameter list',
['$aliases'] = 'parameter aliases',
['$flags'] = 'flags',
['$B'] = 'template content',
['$template-name'] = 'template invocation name override',
}
function p.main(frame, body)
-- If we are substing, this function returns a template invocation, and if
-- not, it returns the template body. The template body can be specified in
-- the body parameter, or in the template parameter defined in the
-- BODY_PARAM variable. This function can be called from Lua or from
-- #invoke.
-- Return the template body if we aren't substing.
if not mw.isSubsting() then
if body ~= nil then
return body
elseif frame.args[BODY_PARAM] ~= nil then
return frame.args[BODY_PARAM]
else
error(string.format(
"no template content specified (use parameter '%s' from #invoke)",
BODY_PARAM
), 2)
end
end
-- Sanity check for the frame object.
if type(frame) ~= 'table'
or type(frame.getParent) ~= 'function'
or not frame:getParent()
then
error(
"argument #1 to 'main' must be a frame object with a parent " ..
"frame available",
2
)
end
-- Find the invocation name.
local mTemplateInvocation = require('Module:Template invocation')
local name
if frame.args['$template-name'] and '' ~= frame.args['$template-name'] then
name = frame.args['$template-name'] -- override whatever the template name is with this name
else
name = mTemplateInvocation.name(frame:getParent():getTitle())
end
-- Combine passed args with passed defaults
local args = {}
if string.find( ','..(frame.args['$flags'] or '')..',', ',%s*override%s*,' ) then
for k, v in pairs( frame:getParent().args ) do
args[k] = v
end
for k, v in pairs( frame.args ) do
if not specialParams[k] then
if v == '__DATE__' then
v = mw.getContentLanguage():formatDate( 'F Y' )
end
args[k] = v
end
end
else
for k, v in pairs( frame.args ) do
if not specialParams[k] then
if v == '__DATE__' then
v = mw.getContentLanguage():formatDate( 'F Y' )
end
args[k] = v
end
end
for k, v in pairs( frame:getParent().args ) do
args[k] = v
end
end
-- Trim parameters, if not specified otherwise
if not string.find( ','..(frame.args['$flags'] or '')..',', ',%s*keep%-whitespace%s*,' ) then
for k, v in pairs( args ) do args[k] = mw.ustring.match(v, '^%s*(.*)%s*$') or '' end
end
-- Pull information from parameter aliases
local aliases = {}
if frame.args['$aliases'] then
local list = mw.text.split( frame.args['$aliases'], '%s*,%s*' )
for k, v in ipairs( list ) do
local tmp = mw.text.split( v, '%s*>%s*' )
aliases[tonumber(mw.ustring.match(tmp[1], '^[1-9][0-9]*$')) or tmp[1]] = ((tonumber(mw.ustring.match(tmp[2], '^[1-9][0-9]*$'))) or tmp[2])
end
end
for k, v in pairs( aliases ) do
if args[k] and ( not args[v] or args[v] == '' ) then
args[v] = args[k]
end
args[k] = nil
end
-- Remove empty parameters, if specified
if string.find( ','..(frame.args['$flags'] or '')..',', ',%s*remove%-empty%s*,' ) then
local tmp = 0
for k, v in ipairs( args ) do
if v ~= '' or ( args[k+1] and args[k+1] ~= '' ) or ( args[k+2] and args[k+2] ~= '' ) then
tmp = k
else
break
end
end
for k, v in pairs( args ) do
if v == '' then
if not (type(k) == 'number' and k < tmp) then args[k] = nil end
end
end
end
-- Order parameters
if frame.args['$params'] then
local params, tmp = mw.text.split( frame.args['$params'], '%s*,%s*' ), {}
for k, v in ipairs(params) do
v = tonumber(mw.ustring.match(v, '^[1-9][0-9]*$')) or v
if args[v] then tmp[v], args[v] = args[v], nil end
end
for k, v in pairs(args) do tmp[k], args[k] = args[k], nil end
args = tmp
end
return mTemplateInvocation.invocation(name, args)
end
p[''] = p.main -- For backwards compatibility
return p
7f01ffc8aa2ac4a4772f14c12e0b77e384ecabb6
Template:Reply to
10
142
287
2021-10-10T15:23:50Z
w>Plastikspork
0
Fix for |=foo bug
wikitext
text/x-wiki
{{<includeonly>safesubst:</includeonly>#invoke:Reply to|replyto|<noinclude>example=Example</noinclude>|max=50}}<noinclude>
{{documentation}}
</noinclude>
3ce97caf39fd21ca2f3a2f4a0be73b1ddd31074e
Template:Module other
10
78
159
2021-10-20T19:50:22Z
Template>MusikBot II
0
Changed protection settings for "[[Template:Module other]]": [[Wikipedia:High-risk templates|High-risk template or module]]: 3570 transclusions ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Require extended confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite))
wikitext
text/x-wiki
{{#switch:
<!--If no or empty "demospace" parameter then detect namespace-->
{{#if:{{{demospace|}}}
| {{lc: {{{demospace}}} }} <!--Use lower case "demospace"-->
| {{#ifeq:{{NAMESPACE}}|{{ns:Module}}
| module
| other
}}
}}
| module = {{{1|}}}
| other
| #default = {{{2|}}}
}}<!--End switch--><noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
503694836c1b07142e63fd35d8be69ec8bb9ffe7
Module:Suppress categories
828
69
141
2021-10-26T17:25:37Z
Template>MusikBot II
0
Changed protection settings for "[[Module:Suppress categories]]": [[Wikipedia:High-risk templates|High-risk template or module]]: 2510 transclusions ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Require extended confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite))
Scribunto
text/plain
-- This is a simple module to strip categories from wikitext. It does
-- not support nested links or magic words like __TOC__, etc. Even so,
-- it should still handle most categories.
local p = {}
-- Detects if a category link is valid or not. If it is valid,
-- the function returns the blank string. If not, the input
-- is returned with no changes.
local function processCategory( all, submatch )
local beforePipe = mw.ustring.match( submatch, '^(.-)[%s_]*|[%s_]*.-$' )
beforePipe = beforePipe or submatch
if mw.ustring.match( beforePipe, '[%[%]<>{}%c\n]' ) then
return all
else
return ''
end
end
-- Preprocess the content if we aren't being called from #invoke,
-- and pass it to gsub to remove valid category links.
local function suppress( content, isPreprocessed )
if not isPreprocessed then
content = mw.getCurrentFrame():preprocess( content )
end
content = mw.ustring.gsub(
content,
'(%[%[[%s_]*[cC][aA][tT][eE][gG][oO][rR][yY][%s_]*:[%s_]*(.-)[%s_]*%]%])',
processCategory
)
return content
end
-- Get the content to suppress categories from, and find
-- whether the content has already been preprocessed. (If the
-- module is called from #invoke, it has been preprocessed already.)
function p.main( frame )
local content, isPreprocessed
if frame == mw.getCurrentFrame() then
content = frame:getParent().args[1]
if frame.args[1] then
content = frame.args[1]
end
isPreprocessed = true
else
content = frame
isPreprocessed = false
end
return suppress( content, isPreprocessed )
end
return p
0ec3903841c489357a879434c5dc23c11d182c78
Template:Terminate sentence
10
158
332
2021-11-29T17:59:48Z
w>MusikBot II
0
Protected "[[Template:Terminate sentence]]": [[Wikipedia:High-risk templates|High-risk template or module]]: 9267 transclusions ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
wikitext
text/x-wiki
{{{1}}}{{#if:{{#invoke:text|sentenceTerminated|{{{1|}}}}}||{{{2|.}}}}}<noinclude>{{documentation}}</noinclude>
e4142b47b3d7959b82f582bab87ca10768d4d93b
Template:Main other
10
14
31
2021-12-10T16:08:06Z
Template>Xaosflux
0
<!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! -->
wikitext
text/x-wiki
{{#switch:
<!--If no or empty "demospace" parameter then detect namespace-->
{{#if:{{{demospace|}}}
| {{lc: {{{demospace}}} }} <!--Use lower case "demospace"-->
| {{#ifeq:{{NAMESPACE}}|{{ns:0}}
| main
| other
}}
}}
| main = {{{1|}}}
| other
| #default = {{{2|}}}
}}<noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! -->
</noinclude>
86ad907ffeea3cc545159e00cd1f2d6433946450
Module:Hatnote list
828
36
75
2021-12-26T20:05:24Z
Template>Nihiltres
0
Undid revision 1062166786 by [[Special:Contributions/Matthiaspaul|Matthiaspaul]] ([[User talk:Matthiaspaul|talk]]); should be fixed now, and if not, please ping me with examples as I couldn't reproduce the original error
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Module:Hatnote list --
-- --
-- This module produces and formats lists for use in hatnotes. In particular, --
-- it implements the for-see list, i.e. lists of "For X, see Y" statements, --
-- as used in {{about}}, {{redirect}}, and their variants. Also introduced --
-- are andList & orList helpers for formatting lists with those conjunctions. --
--------------------------------------------------------------------------------
local mArguments --initialize lazily
local mFormatLink = require('Module:Format link')
local mHatnote = require('Module:Hatnote')
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}
--------------------------------------------------------------------------------
-- List stringification helper functions
--
-- These functions are used for stringifying lists, usually page lists inside
-- the "Y" portion of "For X, see Y" for-see items.
--------------------------------------------------------------------------------
--default options table used across the list stringification functions
local stringifyListDefaultOptions = {
conjunction = "and",
separator = ",",
altSeparator = ";",
space = " ",
formatted = false
}
--Searches display text only
local function searchDisp(haystack, needle)
return string.find(
string.sub(haystack, (string.find(haystack, '|') or 0) + 1), needle
)
end
-- Stringifies a list generically; probably shouldn't be used directly
local function stringifyList(list, options)
-- Type-checks, defaults, and a shortcut
checkType("stringifyList", 1, list, "table")
if #list == 0 then return nil end
checkType("stringifyList", 2, options, "table", true)
options = options or {}
for k, v in pairs(stringifyListDefaultOptions) do
if options[k] == nil then options[k] = v end
end
local s = options.space
-- Format the list if requested
if options.formatted then
list = mFormatLink.formatPages(
{categorizeMissing = mHatnote.missingTargetCat}, list
)
end
-- Set the separator; if any item contains it, use the alternate separator
local separator = options.separator
for k, v in pairs(list) do
if searchDisp(v, separator) then
separator = options.altSeparator
break
end
end
-- Set the conjunction, apply Oxford comma, and force a comma if #1 has "§"
local conjunction = s .. options.conjunction .. s
if #list == 2 and searchDisp(list[1], "§") or #list > 2 then
conjunction = separator .. conjunction
end
-- Return the formatted string
return mw.text.listToText(list, separator .. s, conjunction)
end
--DRY function
function p.conjList (conj, list, fmt)
return stringifyList(list, {conjunction = conj, formatted = fmt})
end
-- Stringifies lists with "and" or "or"
function p.andList (...) return p.conjList("and", ...) end
function p.orList (...) return p.conjList("or", ...) end
--------------------------------------------------------------------------------
-- For see
--
-- Makes a "For X, see [[Y]]." list from raw parameters. Intended for the
-- {{about}} and {{redirect}} templates and their variants.
--------------------------------------------------------------------------------
--default options table used across the forSee family of functions
local forSeeDefaultOptions = {
andKeyword = 'and',
title = mw.title.getCurrentTitle().text,
otherText = 'other uses',
forSeeForm = 'For %s, see %s.',
}
--Collapses duplicate punctuation
local function punctuationCollapse (text)
local replacements = {
["%.%.$"] = ".",
["%?%.$"] = "?",
["%!%.$"] = "!",
["%.%]%]%.$"] = ".]]",
["%?%]%]%.$"] = "?]]",
["%!%]%]%.$"] = "!]]"
}
for k, v in pairs(replacements) do text = string.gsub(text, k, v) end
return text
end
-- Structures arguments into a table for stringification, & options
function p.forSeeArgsToTable (args, from, options)
-- Type-checks and defaults
checkType("forSeeArgsToTable", 1, args, 'table')
checkType("forSeeArgsToTable", 2, from, 'number', true)
from = from or 1
checkType("forSeeArgsToTable", 3, options, 'table', true)
options = options or {}
for k, v in pairs(forSeeDefaultOptions) do
if options[k] == nil then options[k] = v end
end
-- maxArg's gotten manually because getArgs() and table.maxn aren't friends
local maxArg = 0
for k, v in pairs(args) do
if type(k) == 'number' and k > maxArg then maxArg = k end
end
-- Structure the data out from the parameter list:
-- * forTable is the wrapper table, with forRow rows
-- * Rows are tables of a "use" string & a "pages" table of pagename strings
-- * Blanks are left empty for defaulting elsewhere, but can terminate list
local forTable = {}
local i = from
local terminated = false
-- If there is extra text, and no arguments are given, give nil value
-- to not produce default of "For other uses, see foo (disambiguation)"
if options.extratext and i > maxArg then return nil end
-- Loop to generate rows
repeat
-- New empty row
local forRow = {}
-- On blank use, assume list's ended & break at end of this loop
forRow.use = args[i]
if not args[i] then terminated = true end
-- New empty list of pages
forRow.pages = {}
-- Insert first pages item if present
table.insert(forRow.pages, args[i + 1])
-- If the param after next is "and", do inner loop to collect params
-- until the "and"'s stop. Blanks are ignored: "1|and||and|3" → {1, 3}
while args[i + 2] == options.andKeyword do
if args[i + 3] then
table.insert(forRow.pages, args[i + 3])
end
-- Increment to next "and"
i = i + 2
end
-- Increment to next use
i = i + 2
-- Append the row
table.insert(forTable, forRow)
until terminated or i > maxArg
return forTable
end
-- Stringifies a table as formatted by forSeeArgsToTable
function p.forSeeTableToString (forSeeTable, options)
-- Type-checks and defaults
checkType("forSeeTableToString", 1, forSeeTable, "table", true)
checkType("forSeeTableToString", 2, options, "table", true)
options = options or {}
for k, v in pairs(forSeeDefaultOptions) do
if options[k] == nil then options[k] = v end
end
-- Stringify each for-see item into a list
local strList = {}
if forSeeTable then
for k, v in pairs(forSeeTable) do
local useStr = v.use or options.otherText
local pagesStr =
p.andList(v.pages, true) or
mFormatLink._formatLink{
categorizeMissing = mHatnote.missingTargetCat,
link = mHatnote.disambiguate(options.title)
}
local forSeeStr = string.format(options.forSeeForm, useStr, pagesStr)
forSeeStr = punctuationCollapse(forSeeStr)
table.insert(strList, forSeeStr)
end
end
if options.extratext then table.insert(strList, punctuationCollapse(options.extratext..'.')) end
-- Return the concatenated list
return table.concat(strList, ' ')
end
-- Produces a "For X, see [[Y]]" string from arguments. Expects index gaps
-- but not blank/whitespace values. Ignores named args and args < "from".
function p._forSee (args, from, options)
local forSeeTable = p.forSeeArgsToTable(args, from, options)
return p.forSeeTableToString(forSeeTable, options)
end
-- As _forSee, but uses the frame.
function p.forSee (frame, from, options)
mArguments = require('Module:Arguments')
return p._forSee(mArguments.getArgs(frame), from, options)
end
return p
d0828422b1aa0d0d0092d699d059c9e882260398
Template:No redirect
10
129
261
2022-01-02T09:07:18Z
w>Dinoguy1000
0
fix "|=foo" bug
wikitext
text/x-wiki
{{safesubst:<noinclude/>#if: {{safesubst:<noinclude/>#invoke:Redirect|isRedirect|{{{1}}}}}
| <span class="plainlinks">[{{safesubst:<noinclude/>fullurl:{{{1}}}|redirect=no}} {{{2|{{{1}}}}}}]</span>
| {{safesubst:<noinclude/>#if:{{{2|}}}|[[:{{safesubst:<noinclude/>FULLPAGENAME:{{{1}}}}}|{{{2}}}]]|[[:{{safesubst:<noinclude/>FULLPAGENAME:{{{1}}}}}]]}}
}}<noinclude>
{{documentation}}
</noinclude>
1760035b1bed54ee08b810208ed3551b812dfe13
Template:Date
10
100
203
2022-01-02T09:35:32Z
w>Dinoguy1000
0
fix "|=foo" bug
wikitext
text/x-wiki
{{safesubst:<noinclude/>#switch:none
|{{safesubst:<noinclude/>#iferror: {{safesubst:<noinclude/>#time:Y_M_d|{{{1|}}} }} | none }} <noinclude><!-- #time: can't handle --></noinclude>
|{{safesubst:<noinclude/>#iferror: {{safesubst:<noinclude/>#expr: {{{1|}}}+0 }}
|<noinclude><!--not a pure number--></noinclude>
|{{safesubst:<noinclude/>#ifexpr: {{{1|}}}+0 > 10000000000000
|<noinclude><!-- a yyyymmddhhmmss timestamp --></noinclude>
|{{safesubst:<noinclude/>#ifeq: {{safesubst:<noinclude/>#expr:{{{1|}}}+0}} | {{{1|}}}
| none <noinclude><!-- pure number eg 123.456 --></noinclude>
| <noinclude><!-- assume yy-mm-dd --></noinclude>
}}
}}
}}
|{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc:{{{2|}}}}} | none | asis | link | lnone =none }}
|{{safesubst:<noinclude/>#ifexpr: {{safesubst:<noinclude/>#time:Y|{{{1|}}} }} < 1000 | none }}
|{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>#time:Ynj|{{{1|}}} }}|100031|110031|130031|140031|150031=none}}
|= {{safesubst:<noinclude/>#if:{{{1|}}}
|{{safesubst:<noinclude/>#switch:{{{2}}}
|link|lnone|l=[[{{{1}}}]]
|{{{1}}}
}}
}}<noinclude><!-- error or "none", so no formatting --></noinclude>
|<noinclude><!-- continue with formatting --></noinclude>
{{safesubst:<noinclude/>#ifeq:<noinclude><!--
--></noinclude>{{safesubst:<noinclude/>#time:Y|{{{1}}} 2008}}<noinclude><!--
--></noinclude>{{safesubst:<noinclude/>#iferror: {{safesubst:<noinclude/>#ifexpr: {{{1}}}>10000000000000 | no }} | }}<noinclude><!--
--></noinclude>{{safesubst:<noinclude/>#time:Y|{{{1}}} 2004}}
|20082004
|<noinclude><!-- no year --></noinclude>
{{safesubst:<noinclude/>#ifeq:{{safesubst:<noinclude/>#time:d|{{{1}}} 2036}}|{{safesubst:<noinclude/>#time:d|{{{1}}} }}
|<noinclude><!-- month+day --></noinclude>{{safesubst:<noinclude/>#time:
{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc: {{safesubst:<noinclude/>#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
| lmdy | liso | lymd = [[:F j]]
| mdy | iso | ymd = F j
| ldmy | l = [[:j F]]
| #default = j F
}}|{{{1}}} 2000 }}<noinclude><!-- default='dmy' or null or "" or unsupported option --></noinclude>
|<noinclude><!-- month only --></noinclude>{{safesubst:<noinclude/>#time:
{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc: {{safesubst:<noinclude/>#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
| lmdy | liso | lymd
| ldmy | l = [[F]]
| #default = F
}}|{{{1}}} 2000 }}<noinclude><!-- default='dmy'/'mdy'/'ymd'/'iso'/null/""/unsupported opt --></noinclude>
}}
|<noinclude><!-- with year--></noinclude>
{{safesubst:<noinclude/>#if: {{safesubst:<noinclude/>#iferror:{{safesubst:<noinclude/>#time:j|2 {{{1|}}}}}|*D*|{{safesubst:<noinclude/>#iferror:{{safesubst:<noinclude/>#time:j|2000 {{{1|}}}}}|*D*| }}}}
|<noinclude><!-- day+month+year --></noinclude>{{safesubst:<noinclude/>#time:
{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc: {{safesubst:<noinclude/>#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
| lmdy = [[:F j]], [[Y]]
| mdy = F j, Y
| liso = [[Y|Y-]][[F j|m-d]]<noinclude><!-- i.e. [[Y-m-d]] --></noinclude>
| iso = Y-m-d
| lymd = [[Y]] [[:F j]]
| ymd = Y F j
| ldmy | l = [[:j F]] [[Y]]
| #default = j F Y
}}|{{{1|}}} }}<noinclude><!-- #default='dmy' or null or "" or unsupported option --></noinclude>
|<noinclude><!-- month+year --></noinclude>{{safesubst:<noinclude/>#time:
{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc: {{safesubst:<noinclude/>#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
| lmdy | liso | lymd | ldmy | l = [[:F Y]]
| #default = F Y
}}|{{{1|}}} }}<noinclude><!-- default='dmy'/'iso'/'mdy'/null/""/unsupported option --></noinclude>
}}
}}
}}<noinclude>
{{documentation}}
</noinclude>
931e7e4d742cf61660be218f2d435de20a5bcc00
Module:Navbar/styles.css
828
39
81
2022-01-03T23:12:15Z
Template>Izno
0
navbar styles that were moved to parent templates
text
text/plain
/* {{pp|small=yes}} */
.navbar {
display: inline;
font-size: 88%;
font-weight: normal;
}
.navbar-collapse {
float: left;
text-align: left;
}
.navbar-boxtext {
word-spacing: 0;
}
.navbar ul {
display: inline-block;
white-space: nowrap;
line-height: inherit;
}
.navbar-brackets::before {
margin-right: -0.125em;
content: '[ ';
}
.navbar-brackets::after {
margin-left: -0.125em;
content: ' ]';
}
.navbar li {
word-spacing: -0.125em;
}
.navbar a > span,
.navbar a > abbr {
text-decoration: inherit;
}
.navbar-mini abbr {
font-variant: small-caps;
border-bottom: none;
text-decoration: none;
cursor: inherit;
}
.navbar-ct-full {
font-size: 114%;
margin: 0 7em;
}
.navbar-ct-mini {
font-size: 114%;
margin: 0 4em;
}
9d4056f949b4f0b159e3d40dfb1a5f01e72f9571
Template:Small
10
94
191
2022-01-17T03:43:07Z
w>Explicit
0
[[Wikipedia:Templates for discussion/Log/2022 January 10#Template:Smaller]] closed as merge ([[WP:XFDC#4.0.12|XFDcloser]])
wikitext
text/x-wiki
<span style="font-size:85%;">{{{1}}}</span><includeonly>{{SAFESUBST:#if:{{{1|}}}||[[Category:Pages using small with an empty input parameter]]}}</includeonly><noinclude>
{{Documentation}}<!--Categories and interwikis go in the /doc sub-page.-->
</noinclude>
76d3535c2917cc3bfb1b032506073faa15e1a480
Module:Infobox/styles.css
828
19
41
2022-01-18T15:18:00Z
Template>Jdlrobson
0
Fix [[phab:T281642]], a pet peeve of mine. This copies across styles from [[MediaWiki:Minerva.css]]
text
text/plain
/* {{pp|small=y}} */
/*
* This TemplateStyles sheet deliberately does NOT include the full set of
* infobox styles. We are still working to migrate all of the manual
* infoboxes. See [[MediaWiki talk:Common.css/to do#Infobox]]
* DO NOT ADD THEM HERE
*/
/*
* not strictly certain these styles are necessary since the modules now
* exclusively output infobox-subbox or infobox, not both
* just replicating the module faithfully
*/
.infobox-subbox {
padding: 0;
border: none;
margin: -3px;
width: auto;
min-width: 100%;
font-size: 100%;
clear: none;
float: none;
background-color: transparent;
}
.infobox-3cols-child {
margin: auto;
}
.infobox .navbar {
font-size: 100%;
}
/* T281642 */
body.skin-minerva .infobox-header,
body.skin-minerva .infobox-subheader,
body.skin-minerva .infobox-above,
body.skin-minerva .infobox-title,
body.skin-minerva .infobox-image,
body.skin-minerva .infobox-full-data,
body.skin-minerva .infobox-below {
text-align: center;
}
e8de6d96f4fde53afc4a6b0fed534405ab59b0a7
Module:Documentation/config
828
52
107
2022-01-25T23:46:11Z
Template>Ianblair23
0
link
Scribunto
text/plain
----------------------------------------------------------------------------------------------------
--
-- Configuration for Module:Documentation
--
-- Here you can set the values of the parameters and messages used in Module:Documentation to
-- localise it to your wiki and your language. Unless specified otherwise, values given here
-- should be string values.
----------------------------------------------------------------------------------------------------
local cfg = {} -- Do not edit this line.
----------------------------------------------------------------------------------------------------
-- Protection template configuration
----------------------------------------------------------------------------------------------------
-- cfg['protection-reason-edit']
-- The protection reason for edit-protected templates to pass to
-- [[Module:Protection banner]].
cfg['protection-reason-edit'] = 'template'
--[[
----------------------------------------------------------------------------------------------------
-- Sandbox notice configuration
--
-- On sandbox pages the module can display a template notifying users that the current page is a
-- sandbox, and the location of test cases pages, etc. The module decides whether the page is a
-- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the
-- messages that the notices contains.
----------------------------------------------------------------------------------------------------
--]]
-- cfg['sandbox-notice-image']
-- The image displayed in the sandbox notice.
cfg['sandbox-notice-image'] = '[[File:Sandbox.svg|50px|alt=|link=]]'
--[[
-- cfg['sandbox-notice-pagetype-template']
-- cfg['sandbox-notice-pagetype-module']
-- cfg['sandbox-notice-pagetype-other']
-- The page type of the sandbox page. The message that is displayed depends on the current subject
-- namespace. This message is used in either cfg['sandbox-notice-blurb'] or
-- cfg['sandbox-notice-diff-blurb'].
--]]
cfg['sandbox-notice-pagetype-template'] = '[[Wikipedia:Template test cases|template sandbox]] page'
cfg['sandbox-notice-pagetype-module'] = '[[Wikipedia:Template test cases|module sandbox]] page'
cfg['sandbox-notice-pagetype-other'] = 'sandbox page'
--[[
-- cfg['sandbox-notice-blurb']
-- cfg['sandbox-notice-diff-blurb']
-- cfg['sandbox-notice-diff-display']
-- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence
-- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page
-- type, which is either cfg['sandbox-notice-pagetype-template'],
-- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what
-- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between
-- the sandbox and the main template. The display value of the diff link is set by
-- cfg['sandbox-notice-compare-link-display'].
--]]
cfg['sandbox-notice-blurb'] = 'This is the $1 for $2.'
cfg['sandbox-notice-diff-blurb'] = 'This is the $1 for $2 ($3).'
cfg['sandbox-notice-compare-link-display'] = 'diff'
--[[
-- cfg['sandbox-notice-testcases-blurb']
-- cfg['sandbox-notice-testcases-link-display']
-- cfg['sandbox-notice-testcases-run-blurb']
-- cfg['sandbox-notice-testcases-run-link-display']
-- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page
-- corresponding to this sandbox that they can edit. $1 is a link to the test cases page.
-- cfg['sandbox-notice-testcases-link-display'] is the display value for that link.
-- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page
-- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test
-- cases page, and $2 is a link to the page to run it.
-- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test
-- cases.
--]]
cfg['sandbox-notice-testcases-blurb'] = 'See also the companion subpage for $1.'
cfg['sandbox-notice-testcases-link-display'] = 'test cases'
cfg['sandbox-notice-testcases-run-blurb'] = 'See also the companion subpage for $1 ($2).'
cfg['sandbox-notice-testcases-run-link-display'] = 'run'
-- cfg['sandbox-category']
-- A category to add to all template sandboxes.
cfg['sandbox-category'] = 'Template sandboxes'
----------------------------------------------------------------------------------------------------
-- Start box configuration
----------------------------------------------------------------------------------------------------
-- cfg['documentation-icon-wikitext']
-- The wikitext for the icon shown at the top of the template.
cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
-- cfg['template-namespace-heading']
-- The heading shown in the template namespace.
cfg['template-namespace-heading'] = 'Template documentation'
-- cfg['module-namespace-heading']
-- The heading shown in the module namespace.
cfg['module-namespace-heading'] = 'Module documentation'
-- cfg['file-namespace-heading']
-- The heading shown in the file namespace.
cfg['file-namespace-heading'] = 'Summary'
-- cfg['other-namespaces-heading']
-- The heading shown in other namespaces.
cfg['other-namespaces-heading'] = 'Documentation'
-- cfg['view-link-display']
-- The text to display for "view" links.
cfg['view-link-display'] = 'view'
-- cfg['edit-link-display']
-- The text to display for "edit" links.
cfg['edit-link-display'] = 'edit'
-- cfg['history-link-display']
-- The text to display for "history" links.
cfg['history-link-display'] = 'history'
-- cfg['purge-link-display']
-- The text to display for "purge" links.
cfg['purge-link-display'] = 'purge'
-- cfg['create-link-display']
-- The text to display for "create" links.
cfg['create-link-display'] = 'create'
----------------------------------------------------------------------------------------------------
-- Link box (end box) configuration
----------------------------------------------------------------------------------------------------
-- cfg['transcluded-from-blurb']
-- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page.
cfg['transcluded-from-blurb'] = 'The above [[Wikipedia:Template documentation|documentation]] is [[Help:Transclusion|transcluded]] from $1.'
--[[
-- cfg['create-module-doc-blurb']
-- Notice displayed in the module namespace when the documentation subpage does not exist.
-- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the
-- display cfg['create-link-display'].
--]]
cfg['create-module-doc-blurb'] = 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
----------------------------------------------------------------------------------------------------
-- Experiment blurb configuration
----------------------------------------------------------------------------------------------------
--[[
-- cfg['experiment-blurb-template']
-- cfg['experiment-blurb-module']
-- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages.
-- It is only shown in the template and module namespaces. With the default English settings, it
-- might look like this:
--
-- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
--
-- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links.
--
-- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending
-- on what namespace we are in.
--
-- Parameters:
--
-- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format:
--
-- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display'])
--
-- If the sandbox doesn't exist, it is in the format:
--
-- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display'])
--
-- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload']
-- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display']
-- loads a default edit summary of cfg['mirror-edit-summary'].
--
-- $2 is a link to the test cases page. If the test cases page exists, it is in the following format:
--
-- cfg['testcases-link-display'] (cfg['testcases-edit-link-display'] | cfg['testcases-run-link-display'])
--
-- If the test cases page doesn't exist, it is in the format:
--
-- cfg['testcases-link-display'] (cfg['testcases-create-link-display'])
--
-- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the
-- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current
-- namespace.
--]]
cfg['experiment-blurb-template'] = "Editors can experiment in this template's $1 and $2 pages."
cfg['experiment-blurb-module'] = "Editors can experiment in this module's $1 and $2 pages."
----------------------------------------------------------------------------------------------------
-- Sandbox link configuration
----------------------------------------------------------------------------------------------------
-- cfg['sandbox-subpage']
-- The name of the template subpage typically used for sandboxes.
cfg['sandbox-subpage'] = 'sandbox'
-- cfg['template-sandbox-preload']
-- Preload file for template sandbox pages.
cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox'
-- cfg['module-sandbox-preload']
-- Preload file for Lua module sandbox pages.
cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox'
-- cfg['sandbox-link-display']
-- The text to display for "sandbox" links.
cfg['sandbox-link-display'] = 'sandbox'
-- cfg['sandbox-edit-link-display']
-- The text to display for sandbox "edit" links.
cfg['sandbox-edit-link-display'] = 'edit'
-- cfg['sandbox-create-link-display']
-- The text to display for sandbox "create" links.
cfg['sandbox-create-link-display'] = 'create'
-- cfg['compare-link-display']
-- The text to display for "compare" links.
cfg['compare-link-display'] = 'diff'
-- cfg['mirror-edit-summary']
-- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the
-- template page.
cfg['mirror-edit-summary'] = 'Create sandbox version of $1'
-- cfg['mirror-link-display']
-- The text to display for "mirror" links.
cfg['mirror-link-display'] = 'mirror'
-- cfg['mirror-link-preload']
-- The page to preload when a user clicks the "mirror" link.
cfg['mirror-link-preload'] = 'Template:Documentation/mirror'
----------------------------------------------------------------------------------------------------
-- Test cases link configuration
----------------------------------------------------------------------------------------------------
-- cfg['testcases-subpage']
-- The name of the template subpage typically used for test cases.
cfg['testcases-subpage'] = 'testcases'
-- cfg['template-testcases-preload']
-- Preload file for template test cases pages.
cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases'
-- cfg['module-testcases-preload']
-- Preload file for Lua module test cases pages.
cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases'
-- cfg['testcases-link-display']
-- The text to display for "testcases" links.
cfg['testcases-link-display'] = 'testcases'
-- cfg['testcases-edit-link-display']
-- The text to display for test cases "edit" links.
cfg['testcases-edit-link-display'] = 'edit'
-- cfg['testcases-run-link-display']
-- The text to display for test cases "run" links.
cfg['testcases-run-link-display'] = 'run'
-- cfg['testcases-create-link-display']
-- The text to display for test cases "create" links.
cfg['testcases-create-link-display'] = 'create'
----------------------------------------------------------------------------------------------------
-- Add categories blurb configuration
----------------------------------------------------------------------------------------------------
--[[
-- cfg['add-categories-blurb']
-- Text to direct users to add categories to the /doc subpage. Not used if the "content" or
-- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a
-- link to the /doc subpage with a display value of cfg['doc-link-display'].
--]]
cfg['add-categories-blurb'] = 'Add categories to the $1 subpage.'
-- cfg['doc-link-display']
-- The text to display when linking to the /doc subpage.
cfg['doc-link-display'] = '/doc'
----------------------------------------------------------------------------------------------------
-- Subpages link configuration
----------------------------------------------------------------------------------------------------
--[[
-- cfg['subpages-blurb']
-- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a
-- display value of cfg['subpages-link-display']. In the English version this blurb is simply
-- the link followed by a period, and the link display provides the actual text.
--]]
cfg['subpages-blurb'] = '$1.'
--[[
-- cfg['subpages-link-display']
-- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'],
-- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in
-- the template namespace, the module namespace, or another namespace.
--]]
cfg['subpages-link-display'] = 'Subpages of this $1'
-- cfg['template-pagetype']
-- The pagetype to display for template pages.
cfg['template-pagetype'] = 'template'
-- cfg['module-pagetype']
-- The pagetype to display for Lua module pages.
cfg['module-pagetype'] = 'module'
-- cfg['default-pagetype']
-- The pagetype to display for pages other than templates or Lua modules.
cfg['default-pagetype'] = 'page'
----------------------------------------------------------------------------------------------------
-- Doc link configuration
----------------------------------------------------------------------------------------------------
-- cfg['doc-subpage']
-- The name of the subpage typically used for documentation pages.
cfg['doc-subpage'] = 'doc'
-- cfg['docpage-preload']
-- Preload file for template documentation pages in all namespaces.
cfg['docpage-preload'] = 'Template:Documentation/preload'
-- cfg['module-preload']
-- Preload file for Lua module documentation pages.
cfg['module-preload'] = 'Template:Documentation/preload-module-doc'
----------------------------------------------------------------------------------------------------
-- HTML and CSS configuration
----------------------------------------------------------------------------------------------------
-- cfg['templatestyles']
-- The name of the TemplateStyles page where CSS is kept.
-- Sandbox CSS will be at Module:Documentation/sandbox/styles.css when needed.
cfg['templatestyles'] = 'Module:Documentation/styles.css'
-- cfg['container']
-- Class which can be used to set flex or grid CSS on the
-- two child divs documentation and documentation-metadata
cfg['container'] = 'documentation-container'
-- cfg['main-div-classes']
-- Classes added to the main HTML "div" tag.
cfg['main-div-classes'] = 'documentation'
-- cfg['main-div-heading-class']
-- Class for the main heading for templates and modules and assoc. talk spaces
cfg['main-div-heading-class'] = 'documentation-heading'
-- cfg['start-box-class']
-- Class for the start box
cfg['start-box-class'] = 'documentation-startbox'
-- cfg['start-box-link-classes']
-- Classes used for the [view][edit][history] or [create] links in the start box.
-- mw-editsection-like is per [[Wikipedia:Village pump (technical)/Archive 117]]
cfg['start-box-link-classes'] = 'mw-editsection-like plainlinks'
-- cfg['end-box-class']
-- Class for the end box.
cfg['end-box-class'] = 'documentation-metadata'
-- cfg['end-box-plainlinks']
-- Plainlinks
cfg['end-box-plainlinks'] = 'plainlinks'
-- cfg['toolbar-class']
-- Class added for toolbar links.
cfg['toolbar-class'] = 'documentation-toolbar'
-- cfg['clear']
-- Just used to clear things.
cfg['clear'] = 'documentation-clear'
----------------------------------------------------------------------------------------------------
-- Tracking category configuration
----------------------------------------------------------------------------------------------------
-- cfg['display-strange-usage-category']
-- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage
-- or a /testcases subpage. This should be a boolean value (either true or false).
cfg['display-strange-usage-category'] = true
-- cfg['strange-usage-category']
-- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a
-- /doc subpage or a /testcases subpage.
cfg['strange-usage-category'] = 'Wikipedia pages with strange ((documentation)) usage'
--[[
----------------------------------------------------------------------------------------------------
-- End configuration
--
-- Don't edit anything below this line.
----------------------------------------------------------------------------------------------------
--]]
return cfg
71b68ed73088f1a59d61acf06bbee9fde6677f03
Module:TableTools
828
21
45
2022-01-31T13:08:18Z
Template>MSGJ
0
updates/fixes requested by [[User:Uzume]]
Scribunto
text/plain
------------------------------------------------------------------------------------
-- TableTools --
-- --
-- This module includes a number of functions for dealing with Lua tables. --
-- It is a meta-module, meant to be called from other Lua modules, and should not --
-- be called directly from #invoke. --
------------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local p = {}
-- Define often-used variables and functions.
local floor = math.floor
local infinity = math.huge
local checkType = libraryUtil.checkType
local checkTypeMulti = libraryUtil.checkTypeMulti
------------------------------------------------------------------------------------
-- isPositiveInteger
--
-- This function returns true if the given value is a positive integer, and false
-- if not. Although it doesn't operate on tables, it is included here as it is
-- useful for determining whether a given table key is in the array part or the
-- hash part of a table.
------------------------------------------------------------------------------------
function p.isPositiveInteger(v)
return type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity
end
------------------------------------------------------------------------------------
-- isNan
--
-- This function returns true if the given number is a NaN value, and false if
-- not. Although it doesn't operate on tables, it is included here as it is useful
-- for determining whether a value can be a valid table key. Lua will generate an
-- error if a NaN is used as a table key.
------------------------------------------------------------------------------------
function p.isNan(v)
return type(v) == 'number' and v ~= v
end
------------------------------------------------------------------------------------
-- shallowClone
--
-- This returns a clone of a table. The value returned is a new table, but all
-- subtables and functions are shared. Metamethods are respected, but the returned
-- table will have no metatable of its own.
------------------------------------------------------------------------------------
function p.shallowClone(t)
checkType('shallowClone', 1, t, 'table')
local ret = {}
for k, v in pairs(t) do
ret[k] = v
end
return ret
end
------------------------------------------------------------------------------------
-- removeDuplicates
--
-- This removes duplicate values from an array. Non-positive-integer keys are
-- ignored. The earliest value is kept, and all subsequent duplicate values are
-- removed, but otherwise the array order is unchanged.
------------------------------------------------------------------------------------
function p.removeDuplicates(arr)
checkType('removeDuplicates', 1, arr, 'table')
local isNan = p.isNan
local ret, exists = {}, {}
for _, v in ipairs(arr) do
if isNan(v) then
-- NaNs can't be table keys, and they are also unique, so we don't need to check existence.
ret[#ret + 1] = v
else
if not exists[v] then
ret[#ret + 1] = v
exists[v] = true
end
end
end
return ret
end
------------------------------------------------------------------------------------
-- numKeys
--
-- This takes a table and returns an array containing the numbers of any numerical
-- keys that have non-nil values, sorted in numerical order.
------------------------------------------------------------------------------------
function p.numKeys(t)
checkType('numKeys', 1, t, 'table')
local isPositiveInteger = p.isPositiveInteger
local nums = {}
for k in pairs(t) do
if isPositiveInteger(k) then
nums[#nums + 1] = k
end
end
table.sort(nums)
return nums
end
------------------------------------------------------------------------------------
-- affixNums
--
-- This takes a table and returns an array containing the numbers of keys with the
-- specified prefix and suffix. For example, for the table
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", affixNums will return
-- {1, 3, 6}.
------------------------------------------------------------------------------------
function p.affixNums(t, prefix, suffix)
checkType('affixNums', 1, t, 'table')
checkType('affixNums', 2, prefix, 'string', true)
checkType('affixNums', 3, suffix, 'string', true)
local function cleanPattern(s)
-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.
return s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')
end
prefix = prefix or ''
suffix = suffix or ''
prefix = cleanPattern(prefix)
suffix = cleanPattern(suffix)
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'
local nums = {}
for k in pairs(t) do
if type(k) == 'string' then
local num = mw.ustring.match(k, pattern)
if num then
nums[#nums + 1] = tonumber(num)
end
end
end
table.sort(nums)
return nums
end
------------------------------------------------------------------------------------
-- numData
--
-- Given a table with keys like {"foo1", "bar1", "foo2", "baz2"}, returns a table
-- of subtables in the format
-- {[1] = {foo = 'text', bar = 'text'}, [2] = {foo = 'text', baz = 'text'}}.
-- Keys that don't end with an integer are stored in a subtable named "other". The
-- compress option compresses the table so that it can be iterated over with
-- ipairs.
------------------------------------------------------------------------------------
function p.numData(t, compress)
checkType('numData', 1, t, 'table')
checkType('numData', 2, compress, 'boolean', true)
local ret = {}
for k, v in pairs(t) do
local prefix, num = mw.ustring.match(tostring(k), '^([^0-9]*)([1-9][0-9]*)$')
if num then
num = tonumber(num)
local subtable = ret[num] or {}
if prefix == '' then
-- Positional parameters match the blank string; put them at the start of the subtable instead.
prefix = 1
end
subtable[prefix] = v
ret[num] = subtable
else
local subtable = ret.other or {}
subtable[k] = v
ret.other = subtable
end
end
if compress then
local other = ret.other
ret = p.compressSparseArray(ret)
ret.other = other
end
return ret
end
------------------------------------------------------------------------------------
-- compressSparseArray
--
-- This takes an array with one or more nil values, and removes the nil values
-- while preserving the order, so that the array can be safely traversed with
-- ipairs.
------------------------------------------------------------------------------------
function p.compressSparseArray(t)
checkType('compressSparseArray', 1, t, 'table')
local ret = {}
local nums = p.numKeys(t)
for _, num in ipairs(nums) do
ret[#ret + 1] = t[num]
end
return ret
end
------------------------------------------------------------------------------------
-- sparseIpairs
--
-- This is an iterator for sparse arrays. It can be used like ipairs, but can
-- handle nil values.
------------------------------------------------------------------------------------
function p.sparseIpairs(t)
checkType('sparseIpairs', 1, t, 'table')
local nums = p.numKeys(t)
local i = 0
local lim = #nums
return function ()
i = i + 1
if i <= lim then
local key = nums[i]
return key, t[key]
else
return nil, nil
end
end
end
------------------------------------------------------------------------------------
-- size
--
-- This returns the size of a key/value pair table. It will also work on arrays,
-- but for arrays it is more efficient to use the # operator.
------------------------------------------------------------------------------------
function p.size(t)
checkType('size', 1, t, 'table')
local i = 0
for _ in pairs(t) do
i = i + 1
end
return i
end
local function defaultKeySort(item1, item2)
-- "number" < "string", so numbers will be sorted before strings.
local type1, type2 = type(item1), type(item2)
if type1 ~= type2 then
return type1 < type2
elseif type1 == 'table' or type1 == 'boolean' or type1 == 'function' then
return tostring(item1) < tostring(item2)
else
return item1 < item2
end
end
------------------------------------------------------------------------------------
-- keysToList
--
-- Returns an array of the keys in a table, sorted using either a default
-- comparison function or a custom keySort function.
------------------------------------------------------------------------------------
function p.keysToList(t, keySort, checked)
if not checked then
checkType('keysToList', 1, t, 'table')
checkTypeMulti('keysToList', 2, keySort, {'function', 'boolean', 'nil'})
end
local arr = {}
local index = 1
for k in pairs(t) do
arr[index] = k
index = index + 1
end
if keySort ~= false then
keySort = type(keySort) == 'function' and keySort or defaultKeySort
table.sort(arr, keySort)
end
return arr
end
------------------------------------------------------------------------------------
-- sortedPairs
--
-- Iterates through a table, with the keys sorted using the keysToList function.
-- If there are only numerical keys, sparseIpairs is probably more efficient.
------------------------------------------------------------------------------------
function p.sortedPairs(t, keySort)
checkType('sortedPairs', 1, t, 'table')
checkType('sortedPairs', 2, keySort, 'function', true)
local arr = p.keysToList(t, keySort, true)
local i = 0
return function ()
i = i + 1
local key = arr[i]
if key ~= nil then
return key, t[key]
else
return nil, nil
end
end
end
------------------------------------------------------------------------------------
-- isArray
--
-- Returns true if the given value is a table and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArray(v)
if type(v) ~= 'table' then
return false
end
local i = 0
for _ in pairs(v) do
i = i + 1
if v[i] == nil then
return false
end
end
return true
end
------------------------------------------------------------------------------------
-- isArrayLike
--
-- Returns true if the given value is iterable and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArrayLike(v)
if not pcall(pairs, v) then
return false
end
local i = 0
for _ in pairs(v) do
i = i + 1
if v[i] == nil then
return false
end
end
return true
end
------------------------------------------------------------------------------------
-- invert
--
-- Transposes the keys and values in an array. For example, {"a", "b", "c"} ->
-- {a = 1, b = 2, c = 3}. Duplicates are not supported (result values refer to
-- the index of the last duplicate) and NaN values are ignored.
------------------------------------------------------------------------------------
function p.invert(arr)
checkType("invert", 1, arr, "table")
local isNan = p.isNan
local map = {}
for i, v in ipairs(arr) do
if not isNan(v) then
map[v] = i
end
end
return map
end
------------------------------------------------------------------------------------
-- listToSet
--
-- Creates a set from the array part of the table. Indexing the set by any of the
-- values of the array returns true. For example, {"a", "b", "c"} ->
-- {a = true, b = true, c = true}. NaN values are ignored as Lua considers them
-- never equal to any value (including other NaNs or even themselves).
------------------------------------------------------------------------------------
function p.listToSet(arr)
checkType("listToSet", 1, arr, "table")
local isNan = p.isNan
local set = {}
for _, v in ipairs(arr) do
if not isNan(v) then
set[v] = true
end
end
return set
end
------------------------------------------------------------------------------------
-- deepCopy
--
-- Recursive deep copy function. Preserves identities of subtables.
------------------------------------------------------------------------------------
local function _deepCopy(orig, includeMetatable, already_seen)
-- Stores copies of tables indexed by the original table.
already_seen = already_seen or {}
local copy = already_seen[orig]
if copy ~= nil then
return copy
end
if type(orig) == 'table' then
copy = {}
for orig_key, orig_value in pairs(orig) do
copy[_deepCopy(orig_key, includeMetatable, already_seen)] = _deepCopy(orig_value, includeMetatable, already_seen)
end
already_seen[orig] = copy
if includeMetatable then
local mt = getmetatable(orig)
if mt ~= nil then
local mt_copy = _deepCopy(mt, includeMetatable, already_seen)
setmetatable(copy, mt_copy)
already_seen[mt] = mt_copy
end
end
else -- number, string, boolean, etc
copy = orig
end
return copy
end
function p.deepCopy(orig, noMetatable, already_seen)
checkType("deepCopy", 3, already_seen, "table", true)
return _deepCopy(orig, not noMetatable, already_seen)
end
------------------------------------------------------------------------------------
-- sparseConcat
--
-- Concatenates all values in the table that are indexed by a number, in order.
-- sparseConcat{a, nil, c, d} => "acd"
-- sparseConcat{nil, b, c, d} => "bcd"
------------------------------------------------------------------------------------
function p.sparseConcat(t, sep, i, j)
local arr = {}
local arr_i = 0
for _, v in p.sparseIpairs(t) do
arr_i = arr_i + 1
arr[arr_i] = v
end
return table.concat(arr, sep, i, j)
end
------------------------------------------------------------------------------------
-- length
--
-- Finds the length of an array, or of a quasi-array with keys such as "data1",
-- "data2", etc., using an exponential search algorithm. It is similar to the
-- operator #, but may return a different value when there are gaps in the array
-- portion of the table. Intended to be used on data loaded with mw.loadData. For
-- other tables, use #.
-- Note: #frame.args in frame object always be set to 0, regardless of the number
-- of unnamed template parameters, so use this function for frame.args.
------------------------------------------------------------------------------------
function p.length(t, prefix)
-- requiring module inline so that [[Module:Exponential search]] which is
-- only needed by this one function doesn't get millions of transclusions
local expSearch = require("Module:Exponential search")
checkType('length', 1, t, 'table')
checkType('length', 2, prefix, 'string', true)
return expSearch(function (i)
local key
if prefix then
key = prefix .. tostring(i)
else
key = i
end
return t[key] ~= nil
end) or 0
end
------------------------------------------------------------------------------------
-- inArray
--
-- Returns true if valueToFind is a member of the array, and false otherwise.
------------------------------------------------------------------------------------
function p.inArray(arr, valueToFind)
checkType("inArray", 1, arr, "table")
-- if valueToFind is nil, error?
for _, v in ipairs(arr) do
if v == valueToFind then
return true
end
end
return false
end
return p
085e7094ac84eb0132ee65822cf3f69cd8ba3d81
Module:Check for unknown parameters
828
17
37
2022-02-21T05:24:13Z
Template>BusterD
0
Changed protection settings for "[[Module:Check for unknown parameters]]": [[WP:High-risk templates|Highly visible template]]; requested at [[WP:RfPP]] ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))
Scribunto
text/plain
-- This module may be used to compare the arguments passed to the parent
-- with a list of arguments, returning a specified result if an argument is
-- not on the list
local p = {}
local function trim(s)
return s:match('^%s*(.-)%s*$')
end
local function isnotempty(s)
return s and s:match('%S')
end
local function clean(text)
-- Return text cleaned for display and truncated if too long.
-- Strip markers are replaced with dummy text representing the original wikitext.
local pos, truncated
local function truncate(text)
if truncated then
return ''
end
if mw.ustring.len(text) > 25 then
truncated = true
text = mw.ustring.sub(text, 1, 25) .. '...'
end
return mw.text.nowiki(text)
end
local parts = {}
for before, tag, remainder in text:gmatch('([^\127]*)\127[^\127]*%-(%l+)%-[^\127]*\127()') do
pos = remainder
table.insert(parts, truncate(before) .. '<' .. tag .. '>...</' .. tag .. '>')
end
table.insert(parts, truncate(text:sub(pos or 1)))
return table.concat(parts)
end
function p._check(args, pargs)
if type(args) ~= "table" or type(pargs) ~= "table" then
-- TODO: error handling
return
end
-- create the list of known args, regular expressions, and the return string
local knownargs = {}
local regexps = {}
for k, v in pairs(args) do
if type(k) == 'number' then
v = trim(v)
knownargs[v] = 1
elseif k:find('^regexp[1-9][0-9]*$') then
table.insert(regexps, '^' .. v .. '$')
end
end
-- loop over the parent args, and make sure they are on the list
local ignoreblank = isnotempty(args['ignoreblank'])
local showblankpos = isnotempty(args['showblankpositional'])
local values = {}
for k, v in pairs(pargs) do
if type(k) == 'string' and knownargs[k] == nil then
local knownflag = false
for _, regexp in ipairs(regexps) do
if mw.ustring.match(k, regexp) then
knownflag = true
break
end
end
if not knownflag and ( not ignoreblank or isnotempty(v) ) then
table.insert(values, clean(k))
end
elseif type(k) == 'number' and knownargs[tostring(k)] == nil then
local knownflag = false
for _, regexp in ipairs(regexps) do
if mw.ustring.match(tostring(k), regexp) then
knownflag = true
break
end
end
if not knownflag and ( showblankpos or isnotempty(v) ) then
table.insert(values, k .. ' = ' .. clean(v))
end
end
end
-- add results to the output tables
local res = {}
if #values > 0 then
local unknown_text = args['unknown'] or 'Found _VALUE_, '
if mw.getCurrentFrame():preprocess( "{{REVISIONID}}" ) == "" then
local preview_text = args['preview']
if isnotempty(preview_text) then
preview_text = require('Module:If preview')._warning({preview_text})
elseif preview == nil then
preview_text = unknown_text
end
unknown_text = preview_text
end
for _, v in pairs(values) do
-- Fix odd bug for | = which gets stripped to the empty string and
-- breaks category links
if v == '' then v = ' ' end
-- avoid error with v = 'example%2' ("invalid capture index")
local r = unknown_text:gsub('_VALUE_', {_VALUE_ = v})
table.insert(res, r)
end
end
return table.concat(res)
end
function p.check(frame)
local args = frame.args
local pargs = frame:getParent().args
return p._check(args, pargs)
end
return p
93db6d115d4328d2a5148bb42959105e367b663e
Template:Replace
10
145
293
2022-02-23T02:25:08Z
w>Xaosflux
0
Changed protection settings for "[[Template:Replace]]": 1MM+ uses ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))
wikitext
text/x-wiki
{{<includeonly>safesubst:</includeonly>#invoke:String|replace|source={{{1}}}|{{{2}}}|{{{3}}}|plain={{{plain|true}}}|count={{{count|}}}}}<noinclude>
{{documentation}}
</noinclude>
4192ba916713e0f44fdfd0f8e0d9d105c0c85472
Module:Effective protection expiry
828
30
63
2022-02-23T10:59:29Z
Template>Xaosflux
0
Changed protection settings for "[[Module:Effective protection expiry]]": used in the mediawiki interface / match [[Module:Effective protection level]] ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))
Scribunto
text/plain
local p = {}
-- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known.
-- If no title is specified, the title of the page being displayed is used.
function p._main(action, pagename)
local title
if type(pagename) == 'table' and pagename.prefixedText then
title = pagename
elseif pagename then
title = mw.title.new(pagename)
else
title = mw.title.getCurrentTitle()
end
pagename = title.prefixedText
if action == 'autoreview' then
local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title)
return stabilitySettings and stabilitySettings.expiry or 'unknown'
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then
error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )
end
local rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename)
if rawExpiry == 'infinity' then
return 'infinity'
elseif rawExpiry == '' then
return 'unknown'
else
local year, month, day, hour, minute, second = rawExpiry:match(
'^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$'
)
if year then
return string.format(
'%s-%s-%sT%s:%s:%s',
year, month, day, hour, minute, second
)
else
error('internal error in Module:Effective protection expiry; malformed expiry timestamp')
end
end
end
setmetatable(p, { __index = function(t, k)
return function(frame)
return t._main(k, frame.args[1])
end
end })
return p
9a8c58dc2667232ed08a9b206a5d89ca8150312b
Module:Template link general
828
24
51
2022-03-08T08:30:51Z
Template>Primefac
0
update from sandbox - fixes to _show_result and adding _expand
Scribunto
text/plain
-- This implements Template:Tlg
local getArgs = require('Module:Arguments').getArgs
local p = {}
-- Is a string non-empty?
local function _ne(s)
return s ~= nil and s ~= ""
end
local nw = mw.text.nowiki
local function addTemplate(s)
local i, _ = s:find(':', 1, true)
if i == nil then
return 'Template:' .. s
end
local ns = s:sub(1, i - 1)
if ns == '' or mw.site.namespaces[ns] then
return s
else
return 'Template:' .. s
end
end
local function trimTemplate(s)
local needle = 'template:'
if s:sub(1, needle:len()):lower() == needle then
return s:sub(needle:len() + 1)
else
return s
end
end
local function linkTitle(args)
if _ne(args.nolink) then
return args['1']
end
local titleObj
local titlePart = '[['
if args['1'] then
-- This handles :Page and other NS
titleObj = mw.title.new(args['1'], 'Template')
else
titleObj = mw.title.getCurrentTitle()
end
titlePart = titlePart .. (titleObj ~= nil and titleObj.fullText or
addTemplate(args['1']))
local textPart = args.alttext
if not _ne(textPart) then
if titleObj ~= nil then
textPart = titleObj:inNamespace("Template") and args['1'] or titleObj.fullText
else
-- redlink
textPart = args['1']
end
end
if _ne(args.subst) then
-- HACK: the ns thing above is probably broken
textPart = 'subst:' .. textPart
end
if _ne(args.brace) then
textPart = nw('{{') .. textPart .. nw('}}')
elseif _ne(args.braceinside) then
textPart = nw('{') .. textPart .. nw('}')
end
titlePart = titlePart .. '|' .. textPart .. ']]'
if _ne(args.braceinside) then
titlePart = nw('{') .. titlePart .. nw('}')
end
return titlePart
end
function p.main(frame)
local args = getArgs(frame, {
trim = true,
removeBlanks = false
})
return p._main(args)
end
function p._main(args)
local bold = _ne(args.bold) or _ne(args.boldlink) or _ne(args.boldname)
local italic = _ne(args.italic) or _ne(args.italics)
local dontBrace = _ne(args.brace) or _ne(args.braceinside)
local code = _ne(args.code) or _ne(args.tt)
local show_result = _ne(args._show_result)
local expand = _ne(args._expand)
-- Build the link part
local titlePart = linkTitle(args)
if bold then titlePart = "'''" .. titlePart .. "'''" end
if _ne(args.nowrapname) then titlePart = '<span class="nowrap">' .. titlePart .. '</span>' end
-- Build the arguments
local textPart = ""
local textPartBuffer = "|"
local codeArguments = {}
local codeArgumentsString = ""
local i = 2
local j = 1
while args[i] do
local val = args[i]
if val ~= "" then
if _ne(args.nowiki) then
-- Unstrip nowiki tags first because calling nw on something that already contains nowiki tags will
-- mangle the nowiki strip marker and result in literal UNIQ...QINU showing up
val = nw(mw.text.unstripNoWiki(val))
end
local k, v = string.match(val, "(.*)=(.*)")
if not k then
codeArguments[j] = val
j = j + 1
else
codeArguments[k] = v
end
codeArgumentsString = codeArgumentsString .. textPartBuffer .. val
if italic then
val = '<span style="font-style:italic;">' .. val .. '</span>'
end
textPart = textPart .. textPartBuffer .. val
end
i = i + 1
end
-- final wrap
local ret = titlePart .. textPart
if not dontBrace then ret = nw('{{') .. ret .. nw('}}') end
if _ne(args.a) then ret = nw('*') .. ' ' .. ret end
if _ne(args.kbd) then ret = '<kbd>' .. ret .. '</kbd>' end
if code then
ret = '<code>' .. ret .. '</code>'
elseif _ne(args.plaincode) then
ret = '<code style="border:none;background:transparent;">' .. ret .. '</code>'
end
if _ne(args.nowrap) then ret = '<span class="nowrap">' .. ret .. '</span>' end
--[[ Wrap as html??
local span = mw.html.create('span')
span:wikitext(ret)
--]]
if _ne(args.debug) then ret = ret .. '\n<pre>' .. mw.text.encode(mw.dumpObject(args)) .. '</pre>' end
if show_result then
local result = mw.getCurrentFrame():expandTemplate{title = addTemplate(args[1]), args = codeArguments}
ret = ret .. " → " .. result
end
if expand then
local query = mw.text.encode('{{' .. addTemplate(args[1]) .. string.gsub(codeArgumentsString, textPartBuffer, "|") .. '}}')
local url = mw.uri.fullUrl('special:ExpandTemplates', 'wpInput=' .. query)
mw.log()
ret = ret .. " [" .. tostring(url) .. "]"
end
return ret
end
return p
c7307fa3959d308a2dd7fd2f5009c1ce6db3d122
Module:InfoboxImage
828
91
185
2022-03-13T19:18:18Z
w>WOSlinker
0
add class param from sandbox as per edit request
Scribunto
text/plain
-- Inputs:
-- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link
-- page - page to display for multipage images (DjVu)
-- size - size to display the image
-- maxsize - maximum size for image
-- sizedefault - default size to display the image if size param is blank
-- alt - alt text for image
-- title - title text for image
-- border - set to yes if border
-- center - set to yes, if the image has to be centered
-- upright - upright image param
-- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it
-- link - page to visit when clicking on image
-- class - HTML classes to add to the image
-- Outputs:
-- Formatted image.
-- More details available at the "Module:InfoboxImage/doc" page
local i = {};
local placeholder_image = {
"Blue - Replace this image female.svg",
"Blue - Replace this image male.svg",
"Female no free image yet.png",
"Flag of None (square).svg",
"Flag of None.svg",
"Flag of.svg",
"Green - Replace this image female.svg",
"Green - Replace this image male.svg",
"Image is needed female.svg",
"Image is needed male.svg",
"Location map of None.svg",
"Male no free image yet.png",
"Missing flag.png",
"No flag.svg",
"No free portrait.svg",
"No portrait (female).svg",
"No portrait (male).svg",
"Red - Replace this image female.svg",
"Red - Replace this image male.svg",
"Replace this image female (blue).svg",
"Replace this image female.svg",
"Replace this image male (blue).svg",
"Replace this image male.svg",
"Silver - Replace this image female.svg",
"Silver - Replace this image male.svg",
"Replace this image.svg",
"Cricket no pic.png",
"CarersLogo.gif",
"Diagram Needed.svg",
"Example.jpg",
"Image placeholder.png",
"No male portrait.svg",
"Nocover-upload.png",
"NoDVDcover copy.png",
"Noribbon.svg",
"No portrait-BFD-test.svg",
"Placeholder barnstar ribbon.png",
"Project Trains no image.png",
"Image-request.png",
"Sin bandera.svg",
"Sin escudo.svg",
"Replace this image - temple.png",
"Replace this image butterfly.png",
"Replace this image.svg",
"Replace this image1.svg",
"Resolution angle.png",
"Image-No portrait-text-BFD-test.svg",
"Insert image here.svg",
"No image available.png",
"NO IMAGE YET square.png",
"NO IMAGE YET.png",
"No Photo Available.svg",
"No Screenshot.svg",
"No-image-available.jpg",
"Null.png",
"PictureNeeded.gif",
"Place holder.jpg",
"Unbenannt.JPG",
"UploadACopyrightFreeImage.svg",
"UploadAnImage.gif",
"UploadAnImage.svg",
"UploadAnImageShort.svg",
"CarersLogo.gif",
"Diagram Needed.svg",
"No male portrait.svg",
"NoDVDcover copy.png",
"Placeholder barnstar ribbon.png",
"Project Trains no image.png",
"Image-request.png",
"Noimage.gif",
}
function i.IsPlaceholder(image)
-- change underscores to spaces
image = mw.ustring.gsub(image, "_", " ");
assert(image ~= nil, 'mw.ustring.gsub(image, "_", " ") must not return nil')
-- if image starts with [[ then remove that and anything after |
if mw.ustring.sub(image,1,2) == "[[" then
image = mw.ustring.sub(image,3);
image = mw.ustring.gsub(image, "([^|]*)|.*", "%1");
assert(image ~= nil, 'mw.ustring.gsub(image, "([^|]*)|.*", "%1") must not return nil')
end
-- Trim spaces
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
assert(image ~= nil, "mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1') must not return nil")
-- remove prefix if exists
local allNames = mw.site.namespaces[6].aliases
allNames[#allNames + 1] = mw.site.namespaces[6].name
allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName
for i, name in ipairs(allNames) do
if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then
image = mw.ustring.sub(image, mw.ustring.len(name) + 2);
break
end
end
-- Trim spaces
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
-- capitalise first letter
image = mw.ustring.upper(mw.ustring.sub(image,1,1)) .. mw.ustring.sub(image,2);
for i,j in pairs(placeholder_image) do
if image == j then
return true
end
end
return false
end
function i.InfoboxImage(frame)
local image = frame.args["image"];
if image == "" or image == nil then
return "";
end
if image == " " then
return image;
end
if frame.args["suppressplaceholder"] ~= "no" then
if i.IsPlaceholder(image) == true then
return "";
end
end
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "http:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "[http:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[[http:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "https:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[https:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,8)) == "[[https:" then
return "";
end
if mw.ustring.sub(image,1,2) == "[[" then
-- search for thumbnail images and add to tracking cat if found
local cat = "";
if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then
cat = "[[Category:Pages using infoboxes with thumbnail images]]";
end
return image .. cat;
elseif mw.ustring.sub(image,1,2) == "{{" and mw.ustring.sub(image,1,3) ~= "{{{" then
return image;
elseif mw.ustring.sub(image,1,1) == "<" then
return image;
elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then
-- Found strip marker at begining, so pass don't process at all
return image;
elseif mw.ustring.sub(image,4,9) == "`UNIQ-" then
-- Found strip marker at begining, so pass don't process at all
return image;
else
local result = "";
local page = frame.args["page"];
local size = frame.args["size"];
local maxsize = frame.args["maxsize"];
local sizedefault = frame.args["sizedefault"];
local alt = frame.args["alt"];
local link = frame.args["link"];
local title = frame.args["title"];
local border = frame.args["border"];
local upright = frame.args["upright"] or "";
local thumbtime = frame.args["thumbtime"] or "";
local center = frame.args["center"];
local class = frame.args["class"];
-- remove prefix if exists
local allNames = mw.site.namespaces[6].aliases
allNames[#allNames + 1] = mw.site.namespaces[6].name
allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName
for i, name in ipairs(allNames) do
if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then
image = mw.ustring.sub(image, mw.ustring.len(name) + 2);
break
end
end
if maxsize ~= "" and maxsize ~= nil then
-- if no sizedefault then set to maxsize
if sizedefault == "" or sizedefault == nil then
sizedefault = maxsize
end
-- check to see if size bigger than maxsize
if size ~= "" and size ~= nil then
local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0;
local maxsizenumber = tonumber(mw.ustring.match(maxsize,"%d*")) or 0;
if sizenumber>maxsizenumber and maxsizenumber>0 then
size = maxsize;
end
end
end
-- add px to size if just a number
if (tonumber(size) or 0) > 0 then
size = size .. "px";
end
-- add px to sizedefault if just a number
if (tonumber(sizedefault) or 0) > 0 then
sizedefault = sizedefault .. "px";
end
result = "[[File:" .. image;
if page ~= "" and page ~= nil then
result = result .. "|page=" .. page;
end
if size ~= "" and size ~= nil then
result = result .. "|" .. size;
elseif sizedefault ~= "" and sizedefault ~= nil then
result = result .. "|" .. sizedefault;
else
result = result .. "|frameless";
end
if center == "yes" then
result = result .. "|center"
end
if alt ~= "" and alt ~= nil then
result = result .. "|alt=" .. alt;
end
if link ~= "" and link ~= nil then
result = result .. "|link=" .. link;
end
if border == "yes" then
result = result .. "|border";
end
if upright == "yes" then
result = result .. "|upright";
elseif upright ~= "" then
result = result .. "|upright=" .. upright;
end
if thumbtime ~= "" then
result = result .. "|thumbtime=" .. thumbtime;
end
if class ~= nil and class ~= "" then
result = result .. "|class=" .. class;
end
-- if alt value is a keyword then do not use as a description
if alt == "thumbnail" or alt == "thumb" or alt == "frameless" or alt == "left" or alt == "center" or alt == "right" or alt == "upright" or alt == "border" or mw.ustring.match(alt or "", '^[0-9]*px$', 1) ~= nil then
alt = nil;
end
if title ~= "" and title ~= nil then
-- does title param contain any templatestyles? If yes then set to blank.
if mw.ustring.match(frame:preprocess(title), 'UNIQ%-%-templatestyles', 1) ~= nil then
title = nil;
end
end
if title ~= "" and title ~= nil then
result = result .. "|" .. title;
end
result = result .. "]]";
return result;
end
end
return i;
0ee5fe75ba239fc5c9cedc81ca11bdc0be068542
Template:Documentation
10
50
103
2022-03-29T02:14:34Z
Template>Bsherr
0
consistent with new substitution template format
wikitext
text/x-wiki
{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}<noinclude>
<!-- Add categories to the /doc subpage -->
</noinclude>
9e62b964e96c4e3d478edecbfcb3c0338ae8a276
Template:Infobox ship career
10
86
175
2022-05-10T22:28:10Z
w>Galobtter
0
Added {{being deleted}} per [[Wikipedia:Templates for discussion/Log/2022 April 30#Template:Infobox ship begin]] ([[WP:XFDC#4.0.13|XFDcloser]])
wikitext
text/x-wiki
<noinclude>{{Being deleted|2022 April 30|Template:Infobox ship begin|merge= Template:Infobox ship}}</noinclude><includeonly>{{#invoke:WPSHIPS utilities|infobox_ship_career}}</includeonly><noinclude>{{Documentation}}</noinclude>
2eae0adc486cfbc7dc90adf926736348da972150
Template:Infobox ship begin
10
105
213
2022-05-10T22:28:10Z
w>Galobtter
0
Added {{being deleted}} per [[Wikipedia:Templates for discussion/Log/2022 April 30#Template:Infobox ship begin]] ([[WP:XFDC#4.0.13|XFDcloser]])
wikitext
text/x-wiki
<noinclude>{{Being deleted|2022 April 30|Template:Infobox ship begin|merge= Template:Infobox ship}}</noinclude><includeonly>{{WPMILHIST Infobox style|main_box}}
{{#if:{{{infobox caption|}}}|{{!}}+{{#switch:{{{infobox caption}}}
|yes={{#invoke:WPSHIPS_utilities|ship_name_format|name={{PAGENAME}} |adj=off |showerrs={{{showerrs|}}} |sclass={{{sclass|}}}}}<!-- set to 2 for non-italicized class name -->
|nodab={{#invoke:WPSHIPS_utilities|ship_name_format|name={{PAGENAME}}|dab=none |showerrs={{{showerrs|}}} }}
|#default={{{infobox caption}}}}}<!-- end switch -->}}{{#if:{{{display title|}}}|{{#switch:{{{display title}}}|
|none=<!-- do nothing -->
|ital={{italic title}}
|#default={{DISPLAYTITLE:{{{display title}}}}}}}|{{DISPLAYTITLE:{{#invoke:WPSHIPS_utilities|ship_name_format|sclass={{{sclass|}}}|name={{FULLPAGENAME}}}}}}}}</includeonly><noinclude>{{documentation}}</noinclude>
53cce220e7675139aa6cba793b8faec6e8829fe0
Template:Infobox ship characteristics
10
106
215
2022-05-10T22:28:10Z
w>Galobtter
0
Added {{being deleted}} per [[Wikipedia:Templates for discussion/Log/2022 April 30#Template:Infobox ship begin]] ([[WP:XFDC#4.0.13|XFDcloser]])
wikitext
text/x-wiki
<noinclude>{{Being deleted|2022 April 30|Template:Infobox ship begin|merge= Template:Infobox ship}}</noinclude><includeonly>{{#invoke:WPSHIPS utilities|infobox_ship_characteristics}}</includeonly><noinclude>{{Documentation}}</noinclude>
0eb21c64bbfb588d69c0f1c898c9b67540c0b0ac
Template:Infobox ship image
10
107
217
2022-05-10T22:28:10Z
w>Galobtter
0
Added {{being deleted}} per [[Wikipedia:Templates for discussion/Log/2022 April 30#Template:Infobox ship begin]] ([[WP:XFDC#4.0.13|XFDcloser]])
wikitext
text/x-wiki
<noinclude>{{Being deleted|2022 April 30|Template:Infobox ship begin|merge= Template:Infobox ship}}</noinclude><includeonly>| colspan="2" {{WPMILHIST Infobox style|image_box_plain}} | {{#if:{{{image|{{{Ship image|}}}}}}|{{#invoke:InfoboxImage|InfoboxImage|image={{{image|{{{Ship image|}}}}}}|size={{{Ship image size|{{{image size|}}}}}}|sizedefault=300px|upright=1|alt={{{image alt|}}}}}{{#if:{{{caption|{{{Ship caption|}}}}}}|<div>{{{caption|{{{Ship caption|}}}}}}</div>}}|{{#switch:{{NAMESPACENUMBER}}|0|118=[[Category:Ship infoboxes without an image]]}}}}</includeonly>{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using infobox ship image with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Infobox ship image]] with unknown parameter "_VALUE_"|ignoreblank=y| caption | image | image alt | image size | Ship caption | Ship image | Ship image size }}<noinclude>{{Documentation}}</noinclude>
8e5f680a92029e6e100520769241b6951a052cd4
Module:WPSHIPS utilities/data
828
109
221
2022-05-18T17:08:42Z
w>Trappist the monk
0
Scribunto
text/plain
--[[-------------------------< S H I P P R E F I X L I S T >-----------------------------------------------
This is a list of currently supported ship prefixes.
To add to this list the form is:
['prefix'] = true,
the trailing comma is important.
]]
local ship_prefix_t =
{
['ARA'] = true, -- Armada de la República Argentina
['ARC'] = true, -- Armada Nacional de la República de Colombia
['ARM'] = true, -- Armada de la República Mexicana
['ARV'] = true, -- Armada Republica de Venezuela
['BAE'] = true, -- Buque de la Armada de Ecuador
['BAP'] = true, -- Peruvian Navy Ship
['BNS'] = true, -- Bangladesh Navy Ship
['BRP'] = true, -- Barko ng Republika ng Pilipinas
['CCGS'] = true, -- Canadian Coast Guard Ship
['CFAV'] = true, -- Canadian Forces Auxiliary Vessel
['CS'] = true, -- Cable Ship
['CSS'] = true, -- Confederate States Ship
['FGS'] = true, -- Federal German Ship
['GTS'] = true, -- Gas Turbine Ship
['HDMS'] = true, -- His/Her Danish Majesty's Ship
['HM'] = true, -- His/Her Majesty's, then used with the type of ship in military use (UK)
['HMAS'] = true, -- Her/His Majesty's Australian Ship
['HMBS'] = true, -- Her/His Majesty's Britannic Ship (also: Bahamian, Bermudian, Burmese)
['HMC'] = true, -- Her/His Majesty's Cutter
['HMCS'] = true, -- Her/His Majesty's Canadian Ship (also Colonial)
['HMHS'] = true, -- His/Her Majesty's Hospital Ship
['HMIS'] = true, -- Her/His Majesty's Indian Ship (pre republic)
['HMNZS'] = true, -- Her/His Majesty's New Zealand Ship
['HMPNGS'] = true, -- His/Her Majesty's Papua New Guinea Ship
['HMQS'] = true, -- Her/His Majesty's Queensland Ship
['HMRC'] = true, -- His/Her Majesty's Revenue Cutter
['HMS'] = true, -- Her/His Majesty's Ship
['HMSAS'] = true, -- Her/His Majesty's South African Ship
['HMT'] = true, -- Her/His Majesty's Trawler
['HMVS'] = true, -- Her/His Majesty's Victorian Ship
['HMY'] = true, -- His/Her Majesty's Yacht
['HNLMS'] = true, -- His/Her Netherlands Majesty’s Ship
['HNoMS'] = true, -- His/Her Norwegian Majesty's Ship
['HSC'] = true, -- High-Speed Craft
['HSwMS'] = true, -- His/Her Swedish Majesty's Ship
['HTMS'] = true, -- His Thai Majesty's Ship
['ICGS'] = true, -- Indian Coast Guard Ship
['IIS'] = true, -- Imperial Iranian Ship
['INS'] = true, -- Indian Naval Ship, Israeli Naval Ship
['IRIS'] = true, -- Islamic Republic of Iran Ship
['JDS'] = true, -- Japanese Defence Ship
['JS'] = true, -- Japanese Ship (post 2008)
['KA'] = true, -- Kapal Auksiliari – Auxiliary Ship (Malaysia)
['KD'] = true, -- Kapal Di-Raja — His Majesty's Ship (Malaysia)
['KM'] = true, -- Kapal Motor (Motor Ship) (Indonesia)
['KDB'] = true, -- Kapal Diraja Brunei (Royal Brunei Ship) (in Malay)
['KDM'] = true, -- Kongelige Danske Marine
['KLD'] =true, -- Kapal Layar Diraja – His Majesty's Sailing Ship (Malaysia)
['KRI'] = true, -- Kapal Republik Indonesia
['LÉ'] = true, -- Long Éireannach – Irish ship
['MF'] = true, -- Motor Ferry
['LKL'] = true, -- Lietuvos Karinis Laivas – Lithuania
['MS'] = true, -- Motor Ship
['MT'] = true, -- Motor Tanker
['MV'] = true, -- Motor Vessel
['NLV'] = true, -- Northern Lighthouse Vessel
['NMS'] = true, -- Nava Majestăţii Sale (His/Her Majesty's Ship) - used before 1945 by the Royal Romanian Navy
['NoCGV'] = true, -- Norwegian Coast Guard Vessel
['NOAAS'] = true, -- National Oceanic and Atmospheric Administration Ship
['NRP'] = true, -- Navio da República Portuguesa
['ORP'] = true, -- Okręt Rzeczypospolitej Polskiej
['PNS'] = true, -- Pakistani Naval Ship
['PS'] = true, -- Paddle Steamer
['RFA'] = true, -- Royal Fleet Auxiliary
['RMAS'] = true, -- Royal Maritime Auxiliary Service
['RMS'] = true, -- Royal Mail Ship
['RNLB'] = true, -- Royal National Lifeboat
['ROCS'] = true, -- Republic of China Ship
['ROKS'] = true, -- Republic of Korea Ship
['RPS'] = true, -- Republic of the Philippines Ship
['RRS'] = true, -- Royal Research Ship
['RS'] = true, -- Rocket Ship
['RSS'] = true, -- Republic of Singapore Ship
['RV'] = true, -- Research Vessel
['SAS'] = true, -- South African Ship
['SLNS'] = true, -- Sri Lanka Naval Ship
['SM'] = true, -- Seiner Majestät Unterseeboot
['SMS'] = true, -- Seiner Majestät Schiff
['SS'] = true, -- Screw Steamer or Steamship
['STV'] = true, -- Sail training vessel
['TCG'] = true, -- Türkiye Cumhuriyeti Gemisi
['TS'] = true, -- Training ship
['TV'] = true, -- Training vessel
['UAM'] = true, -- Unidade Auxiliar da Marinha - Navy Auxiliary Unit (Portuguese Navy non-military ships)
['USAFS'] = true, -- United States Air Force ship
['USAHS'] = true, -- United States Army Hospital Ship
['USAS'] = true, -- United States Army Ship
['USAT'] = true, -- United States Army Transport
['USAV'] = true, -- United States Army Vessel
['USC&GS'] = true, -- United States Coast and Geodetic Survey
['USC&GS'] = true, -- United States Coast and Geodetic Survey (crude work-around)
['USC&GS'] = true, -- United States Coast and Geodetic Survey (crude work-around)
['USC&GSS'] = true, -- United States Coast and Geodetic Survey Ship
['USC&GSS'] = true, -- United States Coast and Geodetic Survey Ship (crude work-around)
['USC&GSS'] = true, -- United States Coast and Geodetic Survey Ship (crude work-around)
['USCGC'] = true, -- United States Coast Guard Cutter
['USLHT'] = true, -- United State Light House Tender
['USNS'] = true, -- United States Naval Ship
['USRC'] = true, -- United States Revenue Cutter
['USS'] = true, -- United States Ship
}
--[[--------------------------< N A T I O N A L I T Y >--------------------------------------------------------
Article titles for ships in navies that do not use a standardized prefix follow the title format:
<nationality> <ship type> <name> <(disambiguator)>
This is a list of nationalities.
To add to this list the form is:
['Nationality'] = true,
the trailing comma is important. Use the adjective form for nationality, always capitalize. Please insert nationalities in alphabetical order.
]]
local nationality_t =
{
['Albanian'] = true,
['American'] = true,
['Australian'] = true,
['Belgian'] = true,
['Brazilian'] = true,
['Bulgarian'] = true,
['Chilean'] = true,
['Chinese'] = true,
['Croatian'] = true,
['Danish'] = true,
['Dominican'] = true,
['Dutch'] = true,
['East Timorese'] = true,
['Egyptian'] = true,
['English'] = true,
['Finnish'] = true,
['French'] = true,
['German'] = true,
['Greek'] = true,
['Grenadan'] = true,
['Haitian'] = true,
['Iranian'] = true,
['Irish'] = true,
['Italian'] = true,
['Japanese'] = true,
['Latvian'] = true,
['Libyan'] = true,
['Lithuanian'] = true,
['Maltese'] = true,
['Mexican'] = true,
['Nigerian'] = true,
['Ottoman'] = true,
['Peruvian'] = true,
['Portuguese'] = true,
['Romanian'] = true,
['Russian'] = true,
['Scottish'] = true,
['Slovenian'] = true,
['Soviet'] = true,
['Spanish'] = true,
['Swedish'] = true,
['Texan'] = true,
['Ukrainian'] = true,
['United States'] = true,
['Vietnamese'] = true,
['Yugoslav'] = true,
}
--[[--------------------------< S H I P T Y P E >------------------------------------------------------------
Article titles for ships in navies that do not use a standardized prefix follow the title format:
<nationality> <ship type> <name> <(disambiguator)>
Article titles for ships may or may not be naval ships may follow the title format:
<name> <(disambiguator)>
where <(disambiguator)> may be some form of ship type, hull designator or pennant number, or year. This tool will
format ship names that contain a recognized ship type in <(disambiguator)>.
This list is used to <find ship> when the article title begins with a nationality. This is important because the tool
needs to know where the <ship type> ends and <name> begins so that it can properly place the italic markup. The search
will find an exact match (including case) for ship types that are 1 to 4 words long.
This list is also used to find ship type in <(disambiguator)>. The search is whole word; use the simplest form.
For example, because 'icebreaker' is defined, that ship type is sufficient to cause the tool to properly format:
Astrolabe (icebreaker)
Krassin (1917 icebreaker)
Taymyr (nuclear icebreaker)
Searches for ship type in <(disambiguator)> are whole word. When looking for 'ship', the tool will find
Auguste (ship)
Queen of Nations (clipper ship)
but will not find:
Sibir (steamship icebreaker) – the search for 'icebreaker' will
This is a list of ship types. When adding new ship types, do not be too specific: 'aircraft carrier' but not 'light aircraft carrier'
To add to this list the form is:
['ship type'] = true,
the trailing comma is important. At the time of this writing, a ship type may be one to four words, almost always lowercase.
Please insert ship types in alphabetical order.
]]
local ship_type_t =
{
['armoured cruiser'] = true,
['aircraft carrier'] = true,
['amphibious assault ship'] = true,
['Army ship'] = true, -- should be capitalized
['auxiliary cruiser'] = true,
['auxiliary raider'] = true,
['auxiliary'] = true,
['aviso'] = true,
['barge'] = true,
['barque'] = true,
['barquentine'] = true,
['battlecruiser'] = true,
['battleship'] = true,
['boat'] = true,
['brig sloop'] = true,
['brig-sloop'] = true,
['brig'] = true,
['brigantine'] = true,
['carrack'] = true,
['clipper'] = true,
['coast defense ship'] = true,
['coastal defence ship'] = true,
['coastal defense ship'] = true,
['communications ship'] = true,
['corvette'] = true,
['cruiser'] = true,
['cutter'] = true,
['deep submergence rescue vehicle'] = true,
['destroyer leader'] = true,
['destroyer'] = true,
['dragger'] = true,
['dredge'] = true,
['East Indiaman'] = true, -- should be capitalized
['escort ship'] = true,
['escort'] = true,
['ferry'] = true,
['ferryboat'] = true,
['fireboat'] = true,
['fleet oiler'] = true,
['floating battery'] = true,
['floating crane'] = true,
['fluyt'] = true,
['food supply ship'] = true,
['freighter'] = true,
['frigate'] = true,
['galleon'] = true,
['galley'] = true,
['gunboat'] = true,
['helicopter carrier'] = true,
['hospital ship'] = true,
['hovercraft'] = true,
['hydrofoil'] = true,
['icebreaker'] = true,
['Indiaman'] = true, -- should be capitalized
['ironclad'] = true,
['ketch'] = true,
['landing ship'] = true,
['landing ship medium'] = true,
['lifeboat'] = true,
['lightship'] = true,
['log canoe'] = true,
['lugger'] = true,
['merchant cruiser'] = true,
['minehunter'] = true,
['minelayer'] = true,
['minelaying cruiser'] = true,
['minesweeper'] = true,
['missile boat'] = true,
['monitor'] = true,
['munition ship'] = true,
['naval ship'] = true,
['night fighter direction vessel'] = true,
['ocean liner'] = true,
['oiler'] = true,
['paddle steamer'] = true,
['patrol boat'] = true,
['patrol gunboat'] = true,
['patrol vessel'] = true,
['pinnace'] = true,
['pollution control vessel'] = true,
['privateer'] = true,
['protected cruiser'] = true,
['pusher'] = true,
['rescue ship'] = true,
['riverboat'] = true,
['ROV'] = true,
['sailboat'] = true,
['schooner'] = true,
['seaplane carrier'] = true,
['seaplane tender'] = true,
['ship of the line'] = true,
['ship'] = true,
['shipwreck'] = true,
['shore establishment'] = true, -- use stone frigate instead?
['showboat'] = true,
['sidewheeler'] = true,
['skipjack'] = true,
['sloop-of-war'] = true,
['sloop'] = true,
['smack'] = true,
['snagboat'] = true,
['speedboat'] = true,
['steam frigate'] = true,
['steam warship'] = true,
['steamboat'] = true,
['steamer'] = true,
['steamship'] = true,
['sternwheeler'] = true,
['stores lighter'] = true,
['submarine chaser'] = true,
['submarine rescue vehicle'] = true,
['submarine tender'] = true,
['submarine'] = true,
['submersible'] = true,
['supertanker'] = true,
['support ship'] = true,
['survey ship'] = true,
['tanker'] = true,
['target ship'] = true,
['tender'] = true,
['torpedo boat'] = true,
['torpedo gunboat'] = true,
['towboat'] = true,
['training cruiser'] = true,
['training ship'] = true,
['transport'] = true,
['trawler'] = true,
['trireme'] = true,
['tug'] = true,
['tugboat'] = true,
['vessel'] = true,
['warship'] = true,
['weather ship'] = true,
['whaler'] = true,
['whaleship'] = true,
['wherry'] = true,
['yacht'] = true,
['yawl'] = true,
}
--[[--------------------------< I N F O B O X L I N E I T E M P A R A M E T E R S >----------------------
]]
local infobox_career_params_t = { -- table of parameters that are rendered in the same way
['Ship name'] = {1, 'Name'},
['Ship namesake'] = {2, 'Namesake'},
['Ship owner'] = {3, 'Owner'},
['Ship operator'] = {4, 'Operator'},
['Ship registry'] = {5, 'Port of registry'},
['Ship route'] = {6, 'Route'},
['Ship ordered'] = {7, 'Ordered'},
['Ship awarded'] = {8, 'Awarded'},
['Ship builder'] = {9, 'Builder'},
['Ship original cost'] = {10, 'Cost'},
['Ship yard number'] = {11, 'Yard number'},
['Ship way number'] = {12, 'Way number'},
['Ship laid down'] = {13, 'Laid down'},
['Ship launched'] = {14, 'Launched'},
['Ship sponsor'] = {15, 'Sponsored by'},
['Ship christened'] = {16, 'Christened'},
['Ship completed'] = {17, 'Completed'},
['Ship acquired'] = {18, 'Acquired'},
['Ship commissioned'] = {19, 'Commissioned'},
['Ship recommissioned'] = {20, 'Recommissioned'},
['Ship decommissioned'] = {21, 'Decommissioned'},
['Ship maiden voyage'] = {22, 'Maiden voyage'},
['Ship in service'] = {23, 'In service'},
['Ship out of service'] = {24, 'Out of service'},
['Ship renamed'] = {25, 'Renamed'},
['Ship reclassified'] = {26, 'Reclassified'},
['Ship refit'] = {27, 'Refit'},
['Ship struck'] = {28, 'Stricken'},
['Ship stricken'] = {29, 'Stricken'},
['Ship reinstated'] = {30, 'Reinstated'},
['Ship homeport'] = {31, 'Homeport'},
['Ship identification'] = {32, 'Identification'},
['Ship motto'] = {33, 'Motto'},
['Ship nickname'] = {34, 'Nickname(s)'},
['Ship honours'] = {35, 'Honours and<br />awards'}, -- make these two the same index?
['Ship honors'] = {36, 'Honors and<br />awards'},
['Ship captured'] = {37, 'Captured'},
['Ship fate'] = {38, 'Fate'},
['Ship status'] = {39, 'Status'},
['Ship notes'] = {40, 'Notes'},
['Ship badge'] = {41, 'Badge'},
}
local infobox_characteristics_params_t = { -- table of parameters that are rendered in the same way
['Ship class'] = {1, 'Class and type'},
['Ship type'] = {2, 'Type'},
['Ship tonnage'] = {3, 'Tonnage'},
['Ship displacement'] = {4, 'Displacement'},
['Ship tons burthen'] = {5, 'Tons burthen'},
['Ship length'] = {6, 'Length'},
['Ship beam'] = {7, 'Beam'},
['Ship height'] = {8, 'Height'},
['Ship draught'] = {9, 'Draught'}, -- make these two the same index?
['Ship draft'] = {10, 'Draft'},
['Ship depth'] = {11, 'Depth'},
['Ship hold depth'] = {12, 'Depth of hold'},
['Ship decks'] = {13, 'Decks'},
['Ship deck clearance'] = {14, 'Deck clearance'},
['Ship ramps'] = {15, 'Ramps'},
['Ship ice class'] = {16, 'Ice class'},
['Ship power'] = {17, 'Installed power'},
['Ship propulsion'] = {18, 'Propulsion'},
['Ship sail plan'] = {19, 'Sail plan'},
['Ship speed'] = {20, 'Speed'},
['Ship range'] = {21, 'Range'},
['Ship endurance'] = {22, 'Endurance'},
['Ship test depth'] = {23, 'Test depth'},
['Ship boats'] = {24, 'Boats & landing <br /> craft carried'},
['Ship capacity'] = {25, 'Capacity'},
['Ship troops'] = {26, 'Troops'},
['Ship complement'] = {27, 'Complement'},
['Ship crew'] = {28, 'Crew'},
['Ship time to activate'] = {29, 'Time to activate'},
['Ship sensors'] = {30, 'Sensors and <br /> processing systems'},
['Ship EW'] = {31, 'Electronic warfare <br /> & decoys'},
['Ship armament'] = {32, 'Armament'},
['Ship armour'] = {33, 'Armour'}, -- make these two the same index?
['Ship armor'] = {34, 'Armor'},
['Ship aircraft'] = {35, 'Aircraft carried'},
['Ship aircraft facilities'] = {36, 'Aviation facilities'},
['Ship notes'] = {37, 'Notes'},
}
local infobox_class_overview_params_t = { -- table of parameters that are rendered in the same way
['Name'] = {1, 'Name'},
['Builders'] = {2, 'Builders'},
['Operators'] = {3, 'Operators'},
['Class before'] = {4, 'Preceded by'},
['Class after'] = {5, 'Succeeded by'},
['Subclasses'] = {6, 'Subclasses'},
['Cost'] = {7, 'Cost'},
['Built range'] = {8, 'Built'},
['In service range'] = {9, 'In service'},
['In commission range'] = {10, 'In commission'},
['Total ships planned'] = {11, 'Planned'},
['Total ships on order'] = {12, 'On order'},
['Total ships building'] = {13, 'Building'},
['Total ships completed'] = {14, 'Completed'},
['Total ships cancelled'] = {15, 'Cancelled'},
['Total ships active'] = {16, 'Active'},
['Total ships laid up'] = {17, 'Laid up'},
['Total ships lost'] = {18, 'Lost'},
['Total ships retired'] = {19, 'Retired'},
['Total ships scrapped'] = {20, 'Scrapped'},
['Total ships preserved'] = {21, 'Preserved'},
}
--[[--------------------------< C I T E P L I M S O L L >----------------------------------------------------
]]
local subtitles_t = {
['C'] = 'Chalutiers &c.', -- French headings used as subtitles; these appear on even page numbers
['F'] = 'Liste des Navires Pourvus de Machines Frigorifiques',
['NV'] = 'Navires à Voiles',
['NVM'] = 'Navires à Vapeur et à Moteurs',
['R'] = 'List of Vessels Fitted with Refrigerating Appliances', -- English headings used as subtitles; these appear on odd page numbers
['SM'] = 'Steamers & Motorships',
['SV'] = 'Sailing Vessels',
['T'] = 'Trawlers &c.',
}
local subtitles_xlate_t = {
['odd'] = { -- |filename= <page_num> is odd (en) so use French subtitle
['C'] = 'T', -- map fr keyword to en keyword
['F'] = 'R',
['NV'] = 'SV',
['NVM'] = 'SM',
},
['even'] = { -- |filename= <page_num> is even (fr) so use English subtitle
['R'] = 'F', -- map en keyword to fr keyword
['SM'] = 'NVM',
['SV'] = 'NV',
['T'] = 'C',
}
}
--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]
return {
infobox_career_params_t = infobox_career_params_t,
infobox_characteristics_params_t = infobox_characteristics_params_t,
infobox_class_overview_params_t = infobox_class_overview_params_t,
nationality_t = nationality_t,
ship_prefix_t = ship_prefix_t,
ship_type_t = ship_type_t,
subtitles_t = subtitles_t,
subtitles_xlate_t = subtitles_xlate_t,
}
b40cd8dd6cdba008208e6f9b0e1f81ae02fb2441
Template:Module rating
10
79
161
2022-06-03T15:10:23Z
Template>The Anome
0
Reverted edits by [[Special:Contribs/Dawn PScLim|Dawn PScLim]] ([[User talk:Dawn PScLim|talk]]) to last version by Alexis Jazz
wikitext
text/x-wiki
<includeonly>{{#ifeq:{{SUBPAGENAME}}|doc|<!--do not show protection level of the module on the doc page, use the second and optionally third parameter if the doc page is also protected -->{{#if:{{{2|}}}|{{Pp|{{{2}}}|action={{{3|}}}}}}}|{{Module other|{{ombox
| type = notice
| image = {{#switch: {{{1|}}}
| pre-alpha | prealpha | pa = [[File:Ambox warning blue construction.svg|40x40px|link=|alt=Pre-alpha]]
| alpha | a = [[File:Alpha lowercase.svg|26x26px|link=|alt=Alpha]]
| beta | b = [[File:Greek lc beta.svg|40x40px|link=|alt=Beta]]
| release | r | general | g = [[File:Green check.svg|40x40px|link=|alt=Ready for use]]
| protected | protect | p = [[File:{{#switch:{{#invoke:Effective protection level|edit|{{#switch:{{SUBPAGENAME}}|doc|sandbox={{FULLBASEPAGENAME}}|{{FULLPAGENAME}}}}}}|autoconfirmed=Semi|extendedconfirmed=Extended|accountcreator|templateeditor=Template|#default=Full}}-protection-shackle.svg|40x40px|link=|alt=Protected]]
| semiprotected | semiprotect | semi =[[File:Semi-protection-shackle.svg|40x40px|link=|alt=Semi-protected]]
}}
| style =
| textstyle =
| text = {{#switch: {{{1|}}}
| pre-alpha | prealpha | pa = This module is rated as [[:Category:Modules in pre-alpha development|pre-alpha]]. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules in pre-alpha development|{{PAGENAME}}]] }}
}}
| alpha | a = This module is rated as [[:Category:Modules in alpha|alpha]]. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules in alpha|{{PAGENAME}}]] }}
}}
| beta | b = This module is rated as [[:Category:Modules in beta|beta]], and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules in beta|{{PAGENAME}}]] }}
}}
| release | r | general | g = This module is rated as [[:Category:Modules for general use|ready for general use]]. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by [[Wikipedia:Template sandbox and test cases|sandbox testing]] rather than repeated trial-and-error editing.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules for general use|{{PAGENAME}}]] }}
}}
| protected | protect | p = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[Wikipedia:Protection policy|protected]] from editing.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules subject to page protection|{{PAGENAME}}]] }}
}}
| semiprotected | semiprotect | semi = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[WP:SEMI|semi-protected]] from editing.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules subject to page protection|{{PAGENAME}}]] }}
}}
| #default = {{error|Module rating is invalid or not specified.}}
}}
}}|{{error|Error: {{tl|Module rating}} must be placed in the Module namespace.}} [[Category:Pages with templates in the wrong namespace]]|demospace={{{demospace|<noinclude>module</noinclude>}}}}}}}</includeonly><noinclude>
{{module rating|release|nocat=true|demospace=module}}
{{documentation}}
<!-- Categories go on the /doc subpage, and interwikis go in Wikidata. -->
</noinclude>
bbd244b3ea2e13ec4c1c810ae44f2f3789a93efc
Module:Labelled list hatnote
828
95
193
2022-06-08T23:33:35Z
w>Nihiltres
0
Fixed iteration-and-removal bug
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Labelled list --
-- --
-- This module does the core work of creating a hatnote composed of a list --
-- prefixed by a colon-terminated label, i.e. "LABEL: [andList of pages]", --
-- for {{see also}} and similar templates. --
--------------------------------------------------------------------------------
local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local yesno --initialize lazily
local p = {}
-- Defaults global to this module
local defaults = {
label = 'See also', --Final fallback for label argument
labelForm = '%s: %s',
prefixes = {'label', 'label ', 'l'},
template = 'Module:Labelled list hatnote'
}
-- Localizable message strings
local msg = {
errorSuffix = '#Errors',
noInputWarning = 'no page names specified',
noOutputWarning =
"'''[[%s]] — no output: none of the target pages exist.'''"
}
-- Helper function that pre-combines display parameters into page arguments.
-- Also compresses sparse arrays, as a desirable side-effect.
function p.preprocessDisplays (args, prefixes)
-- Prefixes specify which parameters, in order, to check for display options
-- They each have numbers auto-appended, e.g. 'label1', 'label 1', & 'l1'
prefixes = prefixes or defaults.prefixes
local indices = {}
local sparsePages = {}
for k, v in pairs(args) do
if type(k) == 'number' then
indices[#indices + 1] = k
local display
for i = 1, #prefixes do
display = args[prefixes[i] .. k]
if display then break end
end
sparsePages[k] = display and
string.format('%s|%s', string.gsub(v, '|.*$', ''), display) or v
end
end
table.sort(indices)
local pages = {}
for k, v in ipairs(indices) do pages[#pages + 1] = sparsePages[v] end
return pages
end
--Helper function to get a page target from a processed page string
--e.g. "Page|Label" → "Page" or "Target" → "Target"
local function getTarget(pagename)
local pipe = string.find(pagename, '|')
return string.sub(pagename, 0, pipe and pipe - 1 or nil)
end
-- Produces a labelled pages-list hatnote.
-- The main frame (template definition) takes 1 or 2 arguments, for a singular
-- and (optionally) plural label respectively:
-- * {{#invoke:Labelled list hatnote|labelledList|Singular label|Plural label}}
-- The resulting template takes pagename & label parameters normally.
function p.labelledList (frame)
mArguments = require('Module:Arguments')
yesno = require('Module:Yesno')
local labels = {frame.args[1] or defaults.label}
labels[2] = frame.args[2] or labels[1]
labels[3] = frame.args[3] --no defaulting
labels[4] = frame.args[4] --no defaulting
local template = frame:getParent():getTitle()
local args = mArguments.getArgs(frame, {parentOnly = true})
local pages = p.preprocessDisplays(args)
local options = {
category = yesno(args.category),
extraclasses = frame.args.extraclasses,
ifexists = yesno(frame.args.ifexists),
namespace = frame.args.namespace or args.namespace,
selfref = yesno(frame.args.selfref or args.selfref),
template = template
}
return p._labelledList(pages, labels, options)
end
function p._labelledList (pages, labels, options)
if options.ifexists then
for k = #pages, 1, -1 do --iterate backwards to allow smooth removals
local v = pages[k]
local title = mw.title.new(getTarget(v), namespace)
if (v == '') or title == nil or not title.exists then
table.remove(pages, k)
end
end
end
labels = labels or {}
label = (#pages == 1 and labels[1] or labels[2]) or defaults.label
for k, v in pairs(pages) do
if mHatnote.findNamespaceId(v) ~= 0 then
label =
(
#pages == 1 and
(labels[3] or labels[1] or defaults.label) or
(labels[4] or labels[2] or defaults.label)
) or defaults.label
end
end
if #pages == 0 then
if options.ifexists then
mw.addWarning(
string.format(
msg.noOutputWarning, options.template or defaults.template
)
)
return ''
else
return mHatnote.makeWikitextError(
msg.noInputWarning,
(options.template or defaults.template) .. msg.errorSuffix,
options.category
)
end
end
local text = string.format(
options.labelForm or defaults.labelForm,
label,
mHatlist.andList(pages, true)
)
local hnOptions = {
extraclasses = options.extraclasses,
selfref = options.selfref
}
return mHatnote._hatnote(text, hnOptions)
end
return p
b7a8ba27cf6195e6427701b94e8d2acad3c40a21
Template:Clear
10
26
55
2022-06-13T15:31:11Z
Template>Xaosflux
0
Changed protection settings for "[[Template:Clear]]": [[WP:High-risk templates|Highly visible template]]: 3MM+ uses ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))
wikitext
text/x-wiki
<div style="clear:{{{1|both}}};"></div><noinclude>
{{documentation}}
</noinclude>
38bab3e3d7fbd3d6800d46556e60bc6bac494d72
Module:Uses TemplateStyles/config
828
82
167
2022-06-16T15:10:06Z
Template>Pppery
0
Matching reality rather than 2018 me's wishful thinking
Scribunto
text/plain
local cfg = {} -- Don’t touch this line.
-- Subpage blacklist: these subpages will not be categorized (except for the
-- error category, which is always added if there is an error).
-- For example “Template:Foo/doc” matches the `doc = true` rule, so it will have
-- no categories. “Template:Foo” and “Template:Foo/documentation” match no rules,
-- so they *will* have categories. All rules should be in the
-- ['<subpage name>'] = true,
-- format.
cfg['subpage_blacklist'] = {
['doc'] = true,
['sandbox'] = true,
['sandbox2'] = true,
['testcases'] = true,
}
-- Sandbox title: if the stylesheet’s title is <template>/<stylesheet>.css, the
-- stylesheet’s sandbox is expected to be at <template>/<sandbox_title>/<stylesheet>.css
-- Set to nil to disable sandbox links.
cfg['sandbox_title'] = 'sandbox'
-- Error category: this category is added if the module call contains errors
-- (e.g. no stylesheet listed). A category name without namespace, or nil
-- to disable categorization (not recommended).
cfg['error_category'] = 'Uses TemplateStyles templates with errors'
-- Default category: this category is added if no custom category is specified
-- in module/template call. A category name without namespace, or nil
-- to disable categorization.
cfg['default_category'] = 'Templates using TemplateStyles'
-- Protection conflict category: this category is added if the protection level
-- of any stylesheet is lower than the protection level of the template. A category name
-- without namespace, or nil to disable categorization (not recommended).
cfg['protection_conflict_category'] = 'Templates using TemplateStyles with a different protection level'
-- Hierarchy of protection levels, used to determine whether one protection level is lower
-- than another and thus should populate protection_conflict_category. No protection is treated as zero
cfg['protection_hierarchy'] = {
autoconfirmed = 1,
extendedconfirmed = 2,
templateeditor = 3,
sysop = 4
}
-- Padlock pattern: Lua pattern to search on protected stylesheets for, or nil
-- to disable padlock check.
cfg['padlock_pattern'] = '{{pp-'
-- Missing padlock category: this category is added if a protected stylesheet
-- doesn’t contain any padlock template (specified by the above Lua pattern).
-- A category name without namespace (no nil allowed) if the pattern is not nil,
-- unused (and thus may be nil) otherwise.
cfg['missing_padlock_category'] = 'Templates using TemplateStyles without padlocks'
return cfg -- Don’t touch this line.
58e7a37c44f6ea3f6b8af54a559d696cc7256493
Module:Uses TemplateStyles
828
81
165
2022-06-16T15:13:38Z
Template>Pppery
0
Matching reality rather than 2018 me's wishful thinking
Scribunto
text/plain
local yesno = require('Module:Yesno')
local mList = require('Module:List')
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')
local TNT = require('Module:TNT')
local p = {}
local function format(msg, ...)
return TNT.format('I18n/Uses TemplateStyles', msg, ...)
end
local function getConfig()
return mw.loadData('Module:Uses TemplateStyles/config')
end
local function renderBox(tStyles)
local boxArgs = {
type = 'notice',
small = true,
image = string.format('[[File:Farm-Fresh css add.svg|32px|alt=%s]]', format('logo-alt'))
}
if #tStyles < 1 then
boxArgs.text = string.format('<strong class="error">%s</strong>', format('error-emptylist'))
else
local cfg = getConfig()
local tStylesLinks = {}
for i, ts in ipairs(tStyles) do
local link = string.format('[[:%s]]', ts)
local sandboxLink = nil
local tsTitle = mw.title.new(ts)
if tsTitle and cfg['sandbox_title'] then
local tsSandboxTitle = mw.title.new(string.format(
'%s:%s/%s/%s', tsTitle.nsText, tsTitle.baseText, cfg['sandbox_title'], tsTitle.subpageText))
if tsSandboxTitle and tsSandboxTitle.exists then
sandboxLink = format('sandboxlink', link, ':' .. tsSandboxTitle.prefixedText)
end
end
tStylesLinks[i] = sandboxLink or link
end
local tStylesList = mList.makeList('bulleted', tStylesLinks)
boxArgs.text = format(
mw.title.getCurrentTitle():inNamespaces(828,829) and 'header-module' or 'header-template') ..
'\n' .. tStylesList
end
return mMessageBox.main('mbox', boxArgs)
end
local function renderTrackingCategories(args, tStyles, titleObj)
if yesno(args.nocat) then
return ''
end
local cfg = getConfig()
local cats = {}
-- Error category
if #tStyles < 1 and cfg['error_category'] then
cats[#cats + 1] = cfg['error_category']
end
-- TemplateStyles category
titleObj = titleObj or mw.title.getCurrentTitle()
if (titleObj.namespace == 10 or titleObj.namespace == 828)
and not cfg['subpage_blacklist'][titleObj.subpageText]
then
local category = args.category or cfg['default_category']
if category then
cats[#cats + 1] = category
end
if not yesno(args.noprotcat) and (cfg['protection_conflict_category'] or cfg['padlock_pattern']) then
local currentProt = titleObj.protectionLevels["edit"] and titleObj.protectionLevels["edit"][1] or nil
local addedLevelCat = false
local addedPadlockCat = false
for i, ts in ipairs(tStyles) do
local tsTitleObj = mw.title.new(ts)
local tsProt = tsTitleObj.protectionLevels["edit"] and tsTitleObj.protectionLevels["edit"][1] or nil
if cfg['padlock_pattern'] and tsProt and not addedPadlockCat then
local content = tsTitleObj:getContent()
if not content:find(cfg['padlock_pattern']) then
cats[#cats + 1] = cfg['missing_padlock_category']
addedPadlockCat = true
end
end
if cfg['protection_conflict_category'] and currentProt and tsProt ~= currentProt and not addedLevelCat then
currentProt = cfg['protection_hierarchy'][currentProt] or 0
tsProt = cfg['protection_hierarchy'][tsProt] or 0
if tsProt < currentProt then
addedLevelCat = true
cats[#cats + 1] = cfg['protection_conflict_category']
end
end
end
end
end
for i, cat in ipairs(cats) do
cats[i] = string.format('[[Category:%s]]', cat)
end
return table.concat(cats)
end
function p._main(args, cfg)
local tStyles = mTableTools.compressSparseArray(args)
local box = renderBox(tStyles)
local trackingCategories = renderTrackingCategories(args, tStyles)
return box .. trackingCategories
end
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('^%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
return p
71ca57c37849f38e3c5ee30061bdae730963e48e
Template:Country data Spain
10
101
205
2022-07-04T17:08:31Z
w>Skjoldbro
0
updated air force
wikitext
text/x-wiki
{{ {{{1<noinclude>|country showdata</noinclude>}}}
| alias = Spain
| flag alias = Flag of Spain.svg
| flag alias-1506 = Flag of Cross of Burgundy.svg
| flag alias-1701 = Bandera de España 1701-1748.svg
| flag alias-1748 = Bandera de España 1748-1785.svg
| flag alias-1760 = Bandera de España 1760-1785.svg
| flag alias-1785 = Flag of Spain (1785–1873, 1875–1931).svg
| flag alias-1873 = Flag of the First Spanish Republic.svg
| flag alias-1874 = Flag of Spain (1785–1873, 1875–1931).svg
| flag alias-1931 = Flag of Spain (1931–1939).svg
| flag alias-civil-1931 = Flag of the Second Spanish Republic (plain).svg
| flag alias-1936 = Bandera del bando nacional 1936-1938.svg
| flag alias-1938 = Flag of Spain (1938–1945).svg
| flag alias-1945 = Flag of Spain (1945–1977).svg
| flag alias-1977 = Flag of Spain (1977–1981).svg
| flag alias-civil = Flag of Spain (Civil).svg
| flag alias-civil-1785 = BandMercante1785.svg
| flag alias-navy = Flag of Spain.svg
| link alias-navy = Spanish Navy
| flag alias-marines = Flag of Spain.svg
| link alias-marines = Spanish Marine Infantry
| flag alias-army = Flag of Spain.svg
| link alias-army = Spanish Army
| flag alias-naval = Naval Jack of Spain.svg
| link alias-naval = Spanish Navy
| flag alias-air force = Flag of Spain.svg
| link alias-air force = Spanish Air and Space Force
| size = {{{size|}}}
| name = {{{name|}}}
| altlink = {{{altlink|}}}
| variant = {{{variant|}}}
<noinclude>
| var1 = 1506
| var2 = 1701
| var3 = 1748
| var4 = 1760
| var5 = 1785
| var6 = 1873
| var7 = 1874
| var8 = 1931
| var9 = civil-1931
| var10 = 1936
| var11 = 1938
| var12 = 1945
| var13 = 1977
| var14 = civil
| var15 = civil-1785
| redir1 = ESP
| redir2 = SPA
| related1 = Spanish Empire
| related2 = Kingdom of Spain
| related3 = Spanish Republic
| related4 = Spanish State
| related5 = Francoist Spain
</noinclude>
}}
a27e5d2bc6539467e8a94c500b05f5caf7b87dff
Module:Message box/ombox.css
828
73
149
2022-07-11T18:40:17Z
Template>Izno
0
and move mbox-small to 720px here as well
text
text/plain
/* {{pp|small=y}} */
.ombox {
margin: 4px 0;
border-collapse: collapse;
border: 1px solid #a2a9b1; /* Default "notice" gray */
background-color: #f8f9fa;
box-sizing: border-box;
}
/* For the "small=yes" option. */
.ombox.mbox-small {
font-size: 88%;
line-height: 1.25em;
}
.ombox-speedy {
border: 2px solid #b32424; /* Red */
background-color: #fee7e6; /* Pink */
}
.ombox-delete {
border: 2px solid #b32424; /* Red */
}
.ombox-content {
border: 1px solid #f28500; /* Orange */
}
.ombox-style {
border: 1px solid #fc3; /* Yellow */
}
.ombox-move {
border: 1px solid #9932cc; /* Purple */
}
.ombox-protection {
border: 2px solid #a2a9b1; /* Gray-gold */
}
.ombox .mbox-text {
border: none;
/* @noflip */
padding: 0.25em 0.9em;
width: 100%;
}
.ombox .mbox-image {
border: none;
/* @noflip */
padding: 2px 0 2px 0.9em;
text-align: center;
}
.ombox .mbox-imageright {
border: none;
/* @noflip */
padding: 2px 0.9em 2px 0;
text-align: center;
}
/* An empty narrow cell */
.ombox .mbox-empty-cell {
border: none;
padding: 0;
width: 1px;
}
.ombox .mbox-invalid-type {
text-align: center;
}
@media (min-width: 720px) {
.ombox {
margin: 4px 10%;
}
.ombox.mbox-small {
/* @noflip */
clear: right;
/* @noflip */
float: right;
/* @noflip */
margin: 4px 0 4px 1em;
width: 238px;
}
}
8fe3df4bb607e699eab2dbd23bd4a1a446391002
Module:Text
828
157
330
2022-07-21T16:43:48Z
w>Hike395
0
update date
Scribunto
text/plain
local yesNo = require("Module:Yesno")
local Text = { serial = "2022-07-21",
suite = "Text" }
--[=[
Text utilities
]=]
-- local globals
local PatternCJK = false
local PatternCombined = false
local PatternLatin = false
local PatternTerminated = false
local QuoteLang = false
local QuoteType = false
local RangesLatin = false
local SeekQuote = false
local function initLatinData()
if not RangesLatin then
RangesLatin = { { 7, 687 },
{ 7531, 7578 },
{ 7680, 7935 },
{ 8194, 8250 } }
end
if not PatternLatin then
local range
PatternLatin = "^["
for i = 1, #RangesLatin do
range = RangesLatin[ i ]
PatternLatin = PatternLatin ..
mw.ustring.char( range[ 1 ], 45, range[ 2 ] )
end -- for i
PatternLatin = PatternLatin .. "]*$"
end
end
local function initQuoteData()
-- Create quote definitions
if not QuoteLang then
QuoteLang =
{ af = "bd",
ar = "la",
be = "labd",
bg = "bd",
ca = "la",
cs = "bd",
da = "bd",
de = "bd",
dsb = "bd",
et = "bd",
el = "lald",
en = "ld",
es = "la",
eu = "la",
-- fa = "la",
fi = "rd",
fr = "laSPC",
ga = "ld",
he = "ldla",
hr = "bd",
hsb = "bd",
hu = "bd",
hy = "labd",
id = "rd",
is = "bd",
it = "ld",
ja = "x300C",
ka = "bd",
ko = "ld",
lt = "bd",
lv = "bd",
nl = "ld",
nn = "la",
no = "la",
pl = "bdla",
pt = "lald",
ro = "bdla",
ru = "labd",
sk = "bd",
sl = "bd",
sq = "la",
sr = "bx",
sv = "rd",
th = "ld",
tr = "ld",
uk = "la",
zh = "ld",
["de-ch"] = "la",
["en-gb"] = "lsld",
["en-us"] = "ld",
["fr-ch"] = "la",
["it-ch"] = "la",
["pt-br"] = "ldla",
["zh-tw"] = "x300C",
["zh-cn"] = "ld" }
end
if not QuoteType then
QuoteType =
{ bd = { { 8222, 8220 }, { 8218, 8217 } },
bdla = { { 8222, 8220 }, { 171, 187 } },
bx = { { 8222, 8221 }, { 8218, 8217 } },
la = { { 171, 187 }, { 8249, 8250 } },
laSPC = { { 171, 187 }, { 8249, 8250 }, true },
labd = { { 171, 187 }, { 8222, 8220 } },
lald = { { 171, 187 }, { 8220, 8221 } },
ld = { { 8220, 8221 }, { 8216, 8217 } },
ldla = { { 8220, 8221 }, { 171, 187 } },
lsld = { { 8216, 8217 }, { 8220, 8221 } },
rd = { { 8221, 8221 }, { 8217, 8217 } },
x300C = { { 0x300C, 0x300D },
{ 0x300E, 0x300F } } }
end
end -- initQuoteData()
local function fiatQuote( apply, alien, advance )
-- Quote text
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code
-- advance -- number, with level 1 or 2
local r = apply and tostring(apply) or ""
alien = alien or "en"
advance = tonumber(advance) or 0
local suite
initQuoteData()
local slang = alien:match( "^(%l+)-" )
suite = QuoteLang[alien] or slang and QuoteLang[slang] or QuoteLang["en"]
if suite then
local quotes = QuoteType[ suite ]
if quotes then
local space
if quotes[ 3 ] then
space = " "
else
space = ""
end
quotes = quotes[ advance ]
if quotes then
r = mw.ustring.format( "%s%s%s%s%s",
mw.ustring.char( quotes[ 1 ] ),
space,
apply,
space,
mw.ustring.char( quotes[ 2 ] ) )
end
else
mw.log( "fiatQuote() " .. suite )
end
end
return r
end -- fiatQuote()
Text.char = function ( apply, again, accept )
-- Create string from codepoints
-- Parameter:
-- apply -- table (sequence) with numerical codepoints, or nil
-- again -- number of repetitions, or nil
-- accept -- true, if no error messages to be appended
-- Returns: string
local r = ""
apply = type(apply) == "table" and apply or {}
again = math.floor(tonumber(again) or 1)
if again < 1 then
return ""
end
local bad = { }
local codes = { }
for _, v in ipairs( apply ) do
local n = tonumber(v)
if not n or (n < 32 and n ~= 9 and n ~= 10) then
table.insert(bad, tostring(v))
else
table.insert(codes, math.floor(n))
end
end
if #bad > 0 then
if not accept then
r = tostring( mw.html.create( "span" )
:addClass( "error" )
:wikitext( "bad codepoints: " .. table.concat( bad, " " )) )
end
return r
end
if #codes > 0 then
r = mw.ustring.char( unpack( codes ) )
if again > 1 then
r = r:rep(again)
end
end
return r
end -- Text.char()
local function trimAndFormat(args, fmt)
local result = {}
if type(args) ~= 'table' then
args = {args}
end
for _, v in ipairs(args) do
v = mw.text.trim(tostring(v))
if v ~= "" then
table.insert(result,fmt and mw.ustring.format(fmt, v) or v)
end
end
return result
end
Text.concatParams = function ( args, apply, adapt )
-- Concat list items into one string
-- Parameter:
-- args -- table (sequence) with numKey=string
-- apply -- string (optional); separator (default: "|")
-- adapt -- string (optional); format including "%s"
-- Returns: string
local collect = { }
return table.concat(trimAndFormat(args,adapt), apply or "|")
end -- Text.concatParams()
Text.containsCJK = function ( s )
-- Is any CJK code within?
-- Parameter:
-- s -- string
-- Returns: true, if CJK detected
s = s and tostring(s) or ""
if not patternCJK then
patternCJK = mw.ustring.char( 91,
4352, 45, 4607,
11904, 45, 42191,
43072, 45, 43135,
44032, 45, 55215,
63744, 45, 64255,
65072, 45, 65103,
65381, 45, 65500,
131072, 45, 196607,
93 )
end
return mw.ustring.find( s, patternCJK ) ~= nil
end -- Text.containsCJK()
Text.removeDelimited = function (s, prefix, suffix)
-- Remove all text in s delimited by prefix and suffix (inclusive)
-- Arguments:
-- s = string to process
-- prefix = initial delimiter
-- suffix = ending delimiter
-- Returns: stripped string
s = s and tostring(s) or ""
prefix = prefix and tostring(prefix) or ""
suffix = suffix and tostring(suffix) or ""
local prefixLen = mw.ustring.len(prefix)
local suffixLen = mw.ustring.len(suffix)
if prefixLen == 0 or suffixLen == 0 then
return s
end
local i = s:find(prefix, 1, true)
local r = s
local j
while i do
j = r:find(suffix, i + prefixLen)
if j then
r = r:sub(1, i - 1)..r:sub(j+suffixLen)
else
r = r:sub(1, i - 1)
end
i = r:find(prefix, 1, true)
end
return r
end
Text.getPlain = function ( adjust )
-- Remove wikisyntax from string, except templates
-- Parameter:
-- adjust -- string
-- Returns: string
local r = Text.removeDelimited(adjust,"<!--","-->")
r = r:gsub( "(</?%l[^>]*>)", "" )
:gsub( "'''", "" )
:gsub( "''", "" )
:gsub( " ", " " )
return r
end -- Text.getPlain()
Text.isLatinRange = function (s)
-- Are characters expected to be latin or symbols within latin texts?
-- Arguments:
-- s = string to analyze
-- Returns: true, if valid for latin only
s = s and tostring(s) or "" --- ensure input is always string
initLatinData()
return mw.ustring.match(s, PatternLatin) ~= nil
end -- Text.isLatinRange()
Text.isQuote = function ( s )
-- Is this character any quotation mark?
-- Parameter:
-- s = single character to analyze
-- Returns: true, if s is quotation mark
s = s and tostring(s) or ""
if s == "" then
return false
end
if not SeekQuote then
SeekQuote = mw.ustring.char( 34, -- "
39, -- '
171, -- laquo
187, -- raquo
8216, -- lsquo
8217, -- rsquo
8218, -- sbquo
8220, -- ldquo
8221, -- rdquo
8222, -- bdquo
8249, -- lsaquo
8250, -- rsaquo
0x300C, -- CJK
0x300D, -- CJK
0x300E, -- CJK
0x300F ) -- CJK
end
return mw.ustring.find( SeekQuote, s, 1, true ) ~= nil
end -- Text.isQuote()
Text.listToText = function ( args, adapt )
-- Format list items similar to mw.text.listToText()
-- Parameter:
-- args -- table (sequence) with numKey=string
-- adapt -- string (optional); format including "%s"
-- Returns: string
return mw.text.listToText(trimAndFormat(args, adapt))
end -- Text.listToText()
Text.quote = function ( apply, alien, advance )
-- Quote text
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code, or nil
-- advance -- number, with level 1 or 2, or nil
-- Returns: quoted string
apply = apply and tostring(apply) or ""
local mode, slang
if type( alien ) == "string" then
slang = mw.text.trim( alien ):lower()
else
slang = mw.title.getCurrentTitle().pageLanguage
if not slang then
-- TODO FIXME: Introduction expected 2017-04
slang = mw.language.getContentLanguage():getCode()
end
end
if advance == 2 then
mode = 2
else
mode = 1
end
return fiatQuote( mw.text.trim( apply ), slang, mode )
end -- Text.quote()
Text.quoteUnquoted = function ( apply, alien, advance )
-- Quote text, if not yet quoted and not empty
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code, or nil
-- advance -- number, with level 1 or 2, or nil
-- Returns: string; possibly quoted
local r = mw.text.trim( apply and tostring(apply) or "" )
local s = mw.ustring.sub( r, 1, 1 )
if s ~= "" and not Text.isQuote( s, advance ) then
s = mw.ustring.sub( r, -1, 1 )
if not Text.isQuote( s ) then
r = Text.quote( r, alien, advance )
end
end
return r
end -- Text.quoteUnquoted()
Text.removeDiacritics = function ( adjust )
-- Remove all diacritics
-- Parameter:
-- adjust -- string
-- Returns: string; all latin letters should be ASCII
-- or basic greek or cyrillic or symbols etc.
local cleanup, decomposed
if not PatternCombined then
PatternCombined = mw.ustring.char( 91,
0x0300, 45, 0x036F,
0x1AB0, 45, 0x1AFF,
0x1DC0, 45, 0x1DFF,
0xFE20, 45, 0xFE2F,
93 )
end
decomposed = mw.ustring.toNFD( adjust and tostring(adjust) or "" )
cleanup = mw.ustring.gsub( decomposed, PatternCombined, "" )
return mw.ustring.toNFC( cleanup )
end -- Text.removeDiacritics()
Text.sentenceTerminated = function ( analyse )
-- Is string terminated by dot, question or exclamation mark?
-- Quotation, link termination and so on granted
-- Parameter:
-- analyse -- string
-- Returns: true, if sentence terminated
local r
if not PatternTerminated then
PatternTerminated = mw.ustring.char( 91,
12290,
65281,
65294,
65311 )
.. "!%.%?…][\"'%]‹›«»‘’“”]*$"
end
if mw.ustring.find( analyse, PatternTerminated ) then
r = true
else
r = false
end
return r
end -- Text.sentenceTerminated()
Text.ucfirstAll = function ( adjust)
-- Capitalize all words
-- Arguments:
-- adjust = string to adjust
-- Returns: string with all first letters in upper case
adjust = adjust and tostring(adjust) or ""
local r = mw.text.decode(adjust,true)
local i = 1
local c, j, m
m = (r ~= adjust)
r = " "..r
while i do
i = mw.ustring.find( r, "%W%l", i )
if i then
j = i + 1
c = mw.ustring.upper( mw.ustring.sub( r, j, j ) )
r = string.format( "%s%s%s",
mw.ustring.sub( r, 1, i ),
c,
mw.ustring.sub( r, i + 2 ) )
i = j
end
end -- while i
r = r:sub( 2 )
if m then
r = mw.text.encode(r)
end
return r
end -- Text.ucfirstAll()
Text.uprightNonlatin = function ( adjust )
-- Ensure non-italics for non-latin text parts
-- One single greek letter might be granted
-- Precondition:
-- adjust -- string
-- Returns: string with non-latin parts enclosed in <span>
local r
initLatinData()
if mw.ustring.match( adjust, PatternLatin ) then
-- latin only, horizontal dashes, quotes
r = adjust
else
local c
local j = false
local k = 1
local m = false
local n = mw.ustring.len( adjust )
local span = "%s%s<span dir='auto' style='font-style:normal'>%s</span>"
local flat = function ( a )
-- isLatin
local range
for i = 1, #RangesLatin do
range = RangesLatin[ i ]
if a >= range[ 1 ] and a <= range[ 2 ] then
return true
end
end -- for i
end -- flat()
local focus = function ( a )
-- char is not ambivalent
local r = ( a > 64 )
if r then
r = ( a < 8192 or a > 8212 )
else
r = ( a == 38 or a == 60 ) -- '&' '<'
end
return r
end -- focus()
local form = function ( a )
return string.format( span,
r,
mw.ustring.sub( adjust, k, j - 1 ),
mw.ustring.sub( adjust, j, a ) )
end -- form()
r = ""
for i = 1, n do
c = mw.ustring.codepoint( adjust, i, i )
if focus( c ) then
if flat( c ) then
if j then
if m then
if i == m then
-- single greek letter.
j = false
end
m = false
end
if j then
local nx = i - 1
local s = ""
for ix = nx, 1, -1 do
c = mw.ustring.sub( adjust, ix, ix )
if c == " " or c == "(" then
nx = nx - 1
s = c .. s
else
break -- for ix
end
end -- for ix
r = form( nx ) .. s
j = false
k = i
end
end
elseif not j then
j = i
if c >= 880 and c <= 1023 then
-- single greek letter?
m = i + 1
else
m = false
end
end
elseif m then
m = m + 1
end
end -- for i
if j and ( not m or m < n ) then
r = form( n )
else
r = r .. mw.ustring.sub( adjust, k )
end
end
return r
end -- Text.uprightNonlatin()
Text.test = function ( about )
local r
if about == "quote" then
initQuoteData()
r = { }
r.QuoteLang = QuoteLang
r.QuoteType = QuoteType
end
return r
end -- Text.test()
-- Export
local p = { }
for _, func in ipairs({'containsCJK','isLatinRange','isQuote','sentenceTerminated'}) do
p[func] = function (frame)
return Text[func]( frame.args[ 1 ] or "" ) and "1" or ""
end
end
for _, func in ipairs({'getPlain','removeDiacritics','ucfirstAll','uprightNonlatin'}) do
p[func] = function (frame)
return Text[func]( frame.args[ 1 ] or "" )
end
end
function p.char( frame )
local params = frame:getParent().args
local story = params[ 1 ]
local codes, lenient, multiple
if not story then
params = frame.args
story = params[ 1 ]
end
if story then
local items = mw.text.split( mw.text.trim(story), "%s+" )
if #items > 0 then
local j
lenient = (yesNo(params.errors) == false)
codes = { }
multiple = tonumber( params[ "*" ] )
for _, v in ipairs( items ) do
j = tonumber((v:sub( 1, 1 ) == "x" and "0" or "") .. v)
table.insert( codes, j or v )
end
end
end
return Text.char( codes, multiple, lenient )
end
function p.concatParams( frame )
local args
local template = frame.args.template
if type( template ) == "string" then
template = mw.text.trim( template )
template = ( template == "1" )
end
if template then
args = frame:getParent().args
else
args = frame.args
end
return Text.concatParams( args,
frame.args.separator,
frame.args.format )
end
function p.listToFormat(frame)
local lists = {}
local pformat = frame.args["format"]
local sep = frame.args["sep"] or ";"
-- Parameter parsen: Listen
for k, v in pairs(frame.args) do
local knum = tonumber(k)
if knum then lists[knum] = v end
end
-- Listen splitten
local maxListLen = 0
for i = 1, #lists do
lists[i] = mw.text.split(lists[i], sep)
if #lists[i] > maxListLen then maxListLen = #lists[i] end
end
-- Ergebnisstring generieren
local result = ""
local result_line = ""
for i = 1, maxListLen do
result_line = pformat
for j = 1, #lists do
result_line = mw.ustring.gsub(result_line, "%%s", lists[j][i], 1)
end
result = result .. result_line
end
return result
end
function p.listToText( frame )
local args
local template = frame.args.template
if type( template ) == "string" then
template = mw.text.trim( template )
template = ( template == "1" )
end
if template then
args = frame:getParent().args
else
args = frame.args
end
return Text.listToText( args, frame.args.format )
end
function p.quote( frame )
local slang = frame.args[2]
if type( slang ) == "string" then
slang = mw.text.trim( slang )
if slang == "" then
slang = false
end
end
return Text.quote( frame.args[ 1 ] or "",
slang,
tonumber( frame.args[3] ) )
end
function p.quoteUnquoted( frame )
local slang = frame.args[2]
if type( slang ) == "string" then
slang = mw.text.trim( slang )
if slang == "" then
slang = false
end
end
return Text.quoteUnquoted( frame.args[ 1 ] or "",
slang,
tonumber( frame.args[3] ) )
end
function p.zip(frame)
local lists = {}
local seps = {}
local defaultsep = frame.args["sep"] or ""
local innersep = frame.args["isep"] or ""
local outersep = frame.args["osep"] or ""
-- Parameter parsen
for k, v in pairs(frame.args) do
local knum = tonumber(k)
if knum then lists[knum] = v else
if string.sub(k, 1, 3) == "sep" then
local sepnum = tonumber(string.sub(k, 4))
if sepnum then seps[sepnum] = v end
end
end
end
-- sofern keine expliziten Separatoren angegeben sind, den Standardseparator verwenden
for i = 1, math.max(#seps, #lists) do
if not seps[i] then seps[i] = defaultsep end
end
-- Listen splitten
local maxListLen = 0
for i = 1, #lists do
lists[i] = mw.text.split(lists[i], seps[i])
if #lists[i] > maxListLen then maxListLen = #lists[i] end
end
local result = ""
for i = 1, maxListLen do
if i ~= 1 then result = result .. outersep end
for j = 1, #lists do
if j ~= 1 then result = result .. innersep end
result = result .. (lists[j][i] or "")
end
end
return result
end
function p.failsafe()
return Text.serial
end
p.Text = function ()
return Text
end -- p.Text
return p
07f1fc4d39342fd92bdae1c5463bbfede7eeda1a
Template:Para
10
49
101
2022-07-22T08:06:17Z
Template>TheDJ
0
breakup super long words, so we do not overflow the viewport.
wikitext
text/x-wiki
<code class="tpl-para" style="word-break:break-word;{{SAFESUBST:<noinclude />#if:{{{plain|}}}|border: none; background-color: inherit;}} {{SAFESUBST:<noinclude />#if:{{{plain|}}}{{{mxt|}}}{{{green|}}}{{{!mxt|}}}{{{red|}}}|color: {{SAFESUBST:<noinclude />#if:{{{mxt|}}}{{{green|}}}|#006400|{{SAFESUBST:<noinclude />#if:{{{!mxt|}}}{{{red|}}}|#8B0000|inherit}}}};}} {{SAFESUBST:<noinclude />#if:{{{style|}}}|{{{style}}}}}">|{{SAFESUBST:<noinclude />#if:{{{1|}}}|{{{1}}}=}}{{{2|}}}</code><noinclude>
{{Documentation}}
<!--Categories and interwikis go near the bottom of the /doc subpage.-->
</noinclude>
06006deea2ed5d552aab61b4332321ab749ae7e8
Template:Collapse bottom
10
103
209
2022-08-21T18:03:39Z
w>MSGJ
0
Undid revision 1105766128 by [[Special:Contributions/MSGJ|MSGJ]] ([[User talk:MSGJ|talk]]) - did not work
wikitext
text/x-wiki
<includeonly>|}</div></includeonly><noinclude>
{{Documentation|Template:Collapse top/doc}}
<!-- PLEASE ADD THIS TEMPLATE'S CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS -->
</noinclude>
64b210e8ab0882b262da50e9fbccf2132bc34fab
Module:Hatnote
828
34
71
2022-09-05T18:18:32Z
Template>Nihiltres
0
Reordered helper functions (first by export status, then alphabetically) and migrated p.quote upstream from [[Module:Redirect hatnote]] (includes contributions by Tamzin and Nihiltres)
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Module:Hatnote --
-- --
-- This module produces hatnote links and links to related articles. It --
-- implements the {{hatnote}} and {{format link}} meta-templates and includes --
-- helper functions for other Lua hatnote modules. --
--------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg
local mArguments -- lazily initialise [[Module:Arguments]]
local yesno -- lazily initialise [[Module:Yesno]]
local formatLink -- lazily initialise [[Module:Format link]] ._formatLink
local p = {}
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function getArgs(frame)
-- Fetches the arguments from the parent frame. Whitespace is trimmed and
-- blanks are removed.
mArguments = require('Module:Arguments')
return mArguments.getArgs(frame, {parentOnly = true})
end
local function removeInitialColon(s)
-- Removes the initial colon from a string, if present.
return s:match('^:?(.*)')
end
function p.defaultClasses(inline)
-- Provides the default hatnote classes as a space-separated string; useful
-- for hatnote-manipulation modules like [[Module:Hatnote group]].
return
(inline == 1 and 'hatnote-inline' or 'hatnote') .. ' ' ..
'navigation-not-searchable'
end
function p.disambiguate(page, disambiguator)
-- Formats a page title with a disambiguation parenthetical,
-- i.e. "Example" → "Example (disambiguation)".
checkType('disambiguate', 1, page, 'string')
checkType('disambiguate', 2, disambiguator, 'string', true)
disambiguator = disambiguator or 'disambiguation'
return mw.ustring.format('%s (%s)', page, disambiguator)
end
function p.findNamespaceId(link, removeColon)
-- Finds the namespace id (namespace number) of a link or a pagename. This
-- function will not work if the link is enclosed in double brackets. Colons
-- are trimmed from the start of the link by default. To skip colon
-- trimming, set the removeColon parameter to false.
checkType('findNamespaceId', 1, link, 'string')
checkType('findNamespaceId', 2, removeColon, 'boolean', true)
if removeColon ~= false then
link = removeInitialColon(link)
end
local namespace = link:match('^(.-):')
if namespace then
local nsTable = mw.site.namespaces[namespace]
if nsTable then
return nsTable.id
end
end
return 0
end
function p.makeWikitextError(msg, helpLink, addTrackingCategory, title)
-- Formats an error message to be returned to wikitext. If
-- addTrackingCategory is not false after being returned from
-- [[Module:Yesno]], and if we are not on a talk page, a tracking category
-- is added.
checkType('makeWikitextError', 1, msg, 'string')
checkType('makeWikitextError', 2, helpLink, 'string', true)
yesno = require('Module:Yesno')
title = title or mw.title.getCurrentTitle()
-- Make the help link text.
local helpText
if helpLink then
helpText = ' ([[' .. helpLink .. '|help]])'
else
helpText = ''
end
-- Make the category text.
local category
if not title.isTalkPage -- Don't categorise talk pages
and title.namespace ~= 2 -- Don't categorise userspace
and yesno(addTrackingCategory) ~= false -- Allow opting out
then
category = 'Hatnote templates with errors'
category = mw.ustring.format(
'[[%s:%s]]',
mw.site.namespaces[14].name,
category
)
else
category = ''
end
return mw.ustring.format(
'<strong class="error">Error: %s%s.</strong>%s',
msg,
helpText,
category
)
end
local curNs = mw.title.getCurrentTitle().namespace
p.missingTargetCat =
--Default missing target category, exported for use in related modules
((curNs == 0) or (curNs == 14)) and
'Articles with hatnote templates targeting a nonexistent page' or nil
function p.quote(title)
--Wraps titles in quotation marks. If the title starts/ends with a quotation
--mark, kerns that side as with {{-'}}
local quotationMarks = {
["'"]=true, ['"']=true, ['“']=true, ["‘"]=true, ['”']=true, ["’"]=true
}
local quoteLeft, quoteRight = -- Test if start/end are quotation marks
quotationMarks[string.sub(title, 1, 1)],
quotationMarks[string.sub(title, -1, -1)]
if quoteLeft or quoteRight then
title = mw.html.create("span"):wikitext(title)
end
if quoteLeft then title:css("padding-left", "0.15em") end
if quoteRight then title:css("padding-right", "0.15em") end
return '"' .. tostring(title) .. '"'
end
--------------------------------------------------------------------------------
-- Hatnote
--
-- Produces standard hatnote text. Implements the {{hatnote}} template.
--------------------------------------------------------------------------------
function p.hatnote(frame)
local args = getArgs(frame)
local s = args[1]
if not s then
return p.makeWikitextError(
'no text specified',
'Template:Hatnote#Errors',
args.category
)
end
return p._hatnote(s, {
extraclasses = args.extraclasses,
selfref = args.selfref
})
end
function p._hatnote(s, options)
checkType('_hatnote', 1, s, 'string')
checkType('_hatnote', 2, options, 'table', true)
options = options or {}
local inline = options.inline
local hatnote = mw.html.create(inline == 1 and 'span' or 'div')
local extraclasses
if type(options.extraclasses) == 'string' then
extraclasses = options.extraclasses
end
hatnote
:attr('role', 'note')
:addClass(p.defaultClasses(inline))
:addClass(extraclasses)
:addClass(options.selfref and 'selfref' or nil)
:wikitext(s)
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:Hatnote/styles.css' }
} .. tostring(hatnote)
end
return p
3ae1ed7094c5005ca0896395ec9a587287a0bef1
Template:Infobox ship career/doc
10
118
239
2022-09-06T22:56:14Z
w>Getsnoopy
0
Clarified some language.
wikitext
text/x-wiki
{{Documentation subpage}}
{{lua|Module:WPSHIPS utilities}}
This template is part of the WikiProject Ships ship infobox. It adds a Career box to the infobox. Each section, except Infobox Ship Begin, can be repeated as necessary to support multiple careers, multiple sets of characteristics, etc. The header of the Career box can be hidden by setting its "Hide header=yes". This allows you to repeat certain fields by adding a second Career box with a hidden header.{{Infobox ship begin/shared doc}}
===TemplateData===
{{TemplateData header}}
<templatedata>
{
"description": "This template is part of the WikiProject Ships ship infobox. It adds a Career box to the infobox. Each section, except Infobox Ship Begin, can be repeated as necessary to support multiple careers, multiple sets of characteristics, etc. The header of the Career box can be hidden by setting its \"Hide header=yes\". This allows you to repeat certain fields by adding a second Career box with a hidden header.",
"params": {
"Hide header": {
"description": "If you need to repeat fields by using multiple copies of the \"Career\" subtemplate, enter \"Yes\" in this field to prevent display of the blue bar at the top of the second template. At least one \"Career\" header should be left visible.",
"type": "boolean"
},
"Ship country": {
"description": "The nation a ship is associated with; either the nation a warship belongs to, or the nation of registry for civilian ships. However, in case of civilian ships flying flags of convenience, this field should not be used. The country is placed in the infobox header. Do not use this field to indicate ranges.",
"type": "string"
},
"Ship flag": {
"description": "The ensign (maritime flag) associated with a ship",
"type": "string"
},
"Ship class": {
"description": "If the ship belongs to a recognized ship class, use this field to identify the class. The field displays as \"class & type\", so the type should be added here as well.",
"type": "string"
},
"Ship name": {
"description": "The name of the ship",
"type": "string"
},
"Ship namesake": {
"description": "If the ship's name originates from a particular person, location, event, or object, it may be added here. However, descriptions longer than a few words (e.g. a person's name or \"Finnish for \"potato\"\") should be placed in the article body.",
"type": "string"
},
"Ship owner": {
"description": "The company or organisation that owns the vessel. When multiple entries are made in this field, include year ranges. Leave this field blank for warships, as the combination of the |Ship country= and |Ship flag= fields will generally be enough for readers to identify ownership.",
"type": "string"
},
"Ship operator": {
"description": "The company or organisation that operates or runs the ship. If the owner of the vessel is also the operator, this field may be left empty. If it is necessary to mention the charterer of the ship in the infobox, use a separate custom field for that.",
"type": "string"
},
"Ship registry": {
"description": "The nation and port of registry for a civilian vessel. This is generally found painted on the ship's stern. The nation of registry should be expressed as text, not as a flag symbol. A flag symbol may be used in addition, but only if such usage meets Wikipedia:Manual of Style/Icons. When multiple entries are made in this field, include year ranges",
"type": "string"
},
"Ship route": {
"description": "If a civilian or merchant vessel has a long-term (multiple years +) association with a particular voyage path or route. Do not use this field for modern cruise ships, as their routes change on a regular basis.",
"type": "string"
},
"Ship ordered": {
"description": "The date that the ship was ordered from the shipbuilder.",
"type": "string"
},
"Ship awarded": {
"description": "For United States Navy vessels, the date that the contract to build the ships was signed/approved.",
"type": "string"
},
"Ship builder": {
"description": "The shipyard or other construction facility where the vessel was built. Usually, only the building company is listed here. The location of the shipyard may also be added, but avoid too much detail: anything more than a single 'location link' can be discussed in the body of the article or referred to with a link (for example [[Vickers-Armstrongs]], [[Barrow-in-Furness]] or [[BAE Systems Australia]], [[Williamstown, Victoria]], but not [[Scotts Shipbuilding and Engineering Company]], [[Greenock]], [[Scotland]], [[United Kingdom]])",
"type": "string"
},
"Ship original cost": {
"description": "The financial cost of building the ship, usually at the time of construction and using the currency of either the orderer or the builder. If other values are used (e.g. conversions), they should be specified and, if necessary, further discussed in the article",
"type": "string"
},
"Ship yard number": {
"description": "An identifying number assigned for the ship by the builder during construction",
"type": "string"
},
"Ship way number": {
"description": "If the particular slipway where a ship was built has been identified with a number, it may be added here. Rarely used for modern vessels.",
"type": "string"
},
"Ship laid down": {
"description": "The date on which the keel was laid down onto the slipway by the builder. For most ships, this is the point where construction of the vessel starts, and is usually accompanied by ceremony. Although modular construction techniques mean that fabrication of modern vessels can start prior to this, the first time a module is placed on the slipway or building dock is still recognised as the date a ship is laid down.",
"type": "string"
},
"Ship launched": {
"description": "The date a ship is launched, floated out, or other circumstance where the completed hull enters the water. Construction is not normally completed by this date. Take care not to confuse it with dates recognising the ship's entry into service (such as commissioning or maiden voyage)",
"type": "string"
},
"Ship sponsor": {
"description": "The individual (usually a woman and sometimes referred to as a \"launching lady\") who does the whole ceremonial \"smash-the-bottle,-launch-the-ship\" thing as part of the launching ceremony. This is not to be used for any companies or organisations providing sponsorship of a vessel in exchange for advertising or naming rights.",
"type": "string"
},
"Ship christened": {
"description": "The date of the ceremony in which the ship formally and/or ceremonially receives her name (see Ship naming and launching). Only use this field if the naming/christening happened at a separate point in time to either the launching or commissioning ceremonies.",
"type": "string"
},
"Ship completed": {
"description": "The date construction work finished",
"type": "string"
},
"Ship acquired": {
"description": "The date of delivery by the shipbuilder to the owner or operator. If it is the same as the completion date, this field may be left empty. Alternatively, if the ship changes ownership and multiple, separate \"Career\" subtemplates are being used, the date the new owner/operator came into possession of the ship. Do not use this method if the change of ownership is being handled through multiple entries in the |Ship owner= field",
"type": "string"
},
"Ship commissioned": {
"description": "The date a warship was commissioned into naval service.\nDo not use for civilian merchant vessels",
"type": "string"
},
"Ship recommissioned": {
"description": "If a naval vessel was decommissioned from service, then reactivated, use this field to add the new commissioning date\nUsed best with multiple copies of the \"Career\" subtemplate (|Ship commissioned= and |Ship decommissioned= fields in the first template, |Ship recommissioned= and |Ship decommissioned= in the second).\nDo not use for civilian merchant vessels",
"type": "string"
},
"Ship decommissioned": {
"description": "The date a warship was decommissioned or paid off from naval service.\nDo not use this field if events related to the ship's fate (such as loss in action) mean the ship was never formally decommissioned.\nDo not use for civilian merchant vessels.",
"type": "string"
},
"Ship maiden voyage": {
"description": "The dates and locations of the start and end of the ship's maiden voyage: the first recognised voyage in full service, usually carrying passengers or cargo.\nThe transfer of a completed ship from the shipyard to its owner is not normally recognised as a maiden voyage; this is part of the sea trial or shakedown phase, which ensures the ship is working as built.\nMost commonly used for civilian passenger-carrying vessels",
"type": "string"
},
"Ship in service": {
"description": "The date a civilian vessel began operations.\nAlternatively, this may be treated as a date range indicating the start and end points of a ship's career. If being used in this manner, ignore the |Ship out of service= field.",
"type": "string"
},
"Ship out of service": {
"description": "The date a civilian vessel ceased operations.\nIf the |Ship in service= field is being used with a date range instead of a set date, do not use this field.",
"type": "string"
},
"Ship renamed": {
"description": "If the ship changes names, the new names and corresponding dates may be listed here.\nIf multiple names are listed in the |Ship name= field, ignore this field.",
"type": "string"
},
"Ship reclassified": {
"description": "When a warship's classification is altered, the date and new classification may be listed here",
"type": "string"
},
"Ship refit": {
"description": "If the ship underwent a major modification or refit, the start and end dates may be listed here.",
"type": "string"
},
"Ship struck": {
"description": "When a ship is removed from an official register (such as the United States Navy's Naval Vessel Register), the date of removal (or striking) from the register should be listed here.\nThis field does not include collisions, groundings or attacks a ship has experienced.",
"type": "string"
},
"Ship reinstated": {
"description": "If, after a ship has been stricken from a register, she is returned to service and is re-listed on that register, the date of reinstatement should be listed here\nUsed best with multiple copies of the \"Career\" subtemplate.",
"type": "string"
},
"Ship homeport": {
"description": "The home port of the vessel (if different from |Ship registry=): For civilian ships, this will be the primary port from which the ship operates (i.e. for cruise ships, the port in which cruises start and end). Port of registry (the one painted on the stern) should be listed in |Ship registry=. For warships, this will be the ship's assigned naval base.\n\nWhen multiple entries are made in this field, include year ranges.\nFor ships that change their home port on a regular basis (more than once every couple of years), consider ignoring this field and elaborating in the body of the article",
"type": "string"
},
"Ship identification": {
"description": "Any identification numbers or codes for the vessel are listed here. This may include IMO numbers (use {{IMO number}}), MMSI numbers (use {{MMSI}}), Maritime call sign, and pennant/hull numbers (although consider not using the field for hull numbers if these are indicated in the lead sentence of the article).",
"type": "string"
},
"Ship motto": {
"description": "If the ship has a motto, it should be listed here. Wrap non-English mottos in {{lang}} templates followed by the English translation",
"type": "string"
},
"Ship nickname": {
"description": "If the ship has any nicknames, they should be listed here.\nTake care to ensure these are sourced (either in the infobox, or in the body of the article), and consider adding related context and/or circumstances to the article itself.",
"type": "string"
},
"Ship honors": {
"aliases": [
"Ship honours"
],
"description": "Used to list any battle honours, battle stars, unit citations, or other unit awards awarded to the ship for her service.\nDo not list awards given to individuals, even if the award was for service aboard the vessel. Mention these awards in the relevant part of the ship's history.\nAvoid listing annual capability or competition awards (such as the Battle Effectiveness Award or the Gloucester Cup) to avoid bloat. Battle honours of a previous ship with the same name might be appropriate.\nBritish English (honours) and American English (honors) alternatives are provided; delete whichever is inappropriate.",
"type": "string"
},
"Ship captured": {
"description": "When the ship falls into enemy hands, and whose hands they are.\nKeep it brief by only indicating the capturing nation and the date (i.e. \"Antarctica, 30 February 2012\"). Detail relating to the capture should be in the article.\nFollow up with a new \"Career\" subtemplate to discuss the ship's career with her captor.",
"type": "string"
},
"Ship fate": {
"description": "Used to indicate that a ship is no longer operational, and will not return to service in the future. This is usually when something pretty permanent happens to the ship, like sinking or scrapping. Rule of thumb: \"Is the ship permanently below the surface, or in pieces?\"\nOnly list the event and the date it occurred (for example: \"Sank following collision on 10 February 1964\", or \"Sold for scrap in 1975\". Details such as location, cause, etc. should be discussed in the article.\nIn the majority of cases, |Ship status= and |Ship fate= are mutually exclusive. Unlike other redundant fields, leave |Ship fate= in the article, as the ship's life will end one day.",
"type": "string"
},
"Ship status": {
"description": "Used to indicate that a ship is currently in service, or has been removed from service but is available for future use or preserved in some form. Rule of thumb: \"Is the ship above the water and intact?\"\nFor active ships, consider using {{Ship in active service}} or other means to indicate the last known date (generally year) the ship was active. However, if the ship is expected to remain in service in the near future and its decommissioning will not likely go unnoticed, simply |Ship in service= should be enough.\nFor inactive ships, indicate briefly what the ship is 'doing' (laid up, in reserve, preserved as museum ship, awaiting disposal, etc.) and, if deemed necessary, where it is moored.\nIn the majority of cases, |Ship status= and |Ship fate= are mutually exclusive. If the |Ship fate= field is used, delete this field.",
"type": "string"
},
"Ship notes": {
"description": "Any other important information not covered by the other infobox fields, but not important enough for a custom field.\nThis field should not be used for citations/references: either the citations should be attached to the specific entry, or the infobox should be treated as part of the lead section, with the citations attached to the information in the body of the article.",
"type": "string"
},
"Ship badge": {
"description": "An image or description of any naval heraldry, such as the ship's badge or crest, may be added here",
"type": "string"
}
},
"format": "block"
}
</templatedata>
84f7cefd1f90de1f890ed206e0ed507663087f1c
Template:Parameter names example
10
66
135
2022-09-15T17:36:18Z
Template>Aidan9382
0
Hatnote should ideally be moved into documentation as to allow users to edit it regardless of the protection on the main template
wikitext
text/x-wiki
<includeonly>{{#invoke:Parameter names example|main}}</includeonly><noinclude>
{{Documentation}}
</noinclude>
de1e29d6ebc113e9d1649ea6a976625885db8a2f
Module:Format link
828
33
69
2022-10-04T13:37:11Z
Template>Pppery
0
Avoid Lua erroring when we run out of expensive parser function calls
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Format link
--
-- Makes a wikilink from the given link and display values. Links are escaped
-- with colons if necessary, and links to sections are detected and displayed
-- with " § " as a separator rather than the standard MediaWiki "#". Used in
-- the {{format link}} template.
--------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg
local mArguments -- lazily initialise [[Module:Arguments]]
local mError -- lazily initialise [[Module:Error]]
local yesno -- lazily initialise [[Module:Yesno]]
local p = {}
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function getArgs(frame)
-- Fetches the arguments from the parent frame. Whitespace is trimmed and
-- blanks are removed.
mArguments = require('Module:Arguments')
return mArguments.getArgs(frame, {parentOnly = true})
end
local function removeInitialColon(s)
-- Removes the initial colon from a string, if present.
return s:match('^:?(.*)')
end
local function maybeItalicize(s, shouldItalicize)
-- Italicize s if s is a string and the shouldItalicize parameter is true.
if s and shouldItalicize then
return '<i>' .. s .. '</i>'
else
return s
end
end
local function parseLink(link)
-- Parse a link and return a table with the link's components.
-- These components are:
-- - link: the link, stripped of any initial colon (always present)
-- - page: the page name (always present)
-- - section: the page name (may be nil)
-- - display: the display text, if manually entered after a pipe (may be nil)
link = removeInitialColon(link)
-- Find whether a faux display value has been added with the {{!}} magic
-- word.
local prePipe, display = link:match('^(.-)|(.*)$')
link = prePipe or link
-- Find the page, if it exists.
-- For links like [[#Bar]], the page will be nil.
local preHash, postHash = link:match('^(.-)#(.*)$')
local page
if not preHash then
-- We have a link like [[Foo]].
page = link
elseif preHash ~= '' then
-- We have a link like [[Foo#Bar]].
page = preHash
end
-- Find the section, if it exists.
local section
if postHash and postHash ~= '' then
section = postHash
end
return {
link = link,
page = page,
section = section,
display = display,
}
end
local function formatDisplay(parsed, options)
-- Formats a display string based on a parsed link table (matching the
-- output of parseLink) and an options table (matching the input options for
-- _formatLink).
local page = maybeItalicize(parsed.page, options.italicizePage)
local section = maybeItalicize(parsed.section, options.italicizeSection)
if (not section) then
return page
elseif (not page) then
return mw.ustring.format('§ %s', section)
else
return mw.ustring.format('%s § %s', page, section)
end
end
local function missingArgError(target)
mError = require('Module:Error')
return mError.error{message =
'Error: no link or target specified! ([[' .. target .. '#Errors|help]])'
}
end
--------------------------------------------------------------------------------
-- Main functions
--------------------------------------------------------------------------------
function p.formatLink(frame)
-- The formatLink export function, for use in templates.
yesno = require('Module:Yesno')
local args = getArgs(frame)
local link = args[1] or args.link
local target = args[3] or args.target
if not (link or target) then
return missingArgError('Template:Format link')
end
return p._formatLink{
link = link,
display = args[2] or args.display,
target = target,
italicizePage = yesno(args.italicizepage),
italicizeSection = yesno(args.italicizesection),
categorizeMissing = args.categorizemissing
}
end
function p._formatLink(options)
-- The formatLink export function, for use in modules.
checkType('_formatLink', 1, options, 'table')
local function check(key, expectedType) --for brevity
checkTypeForNamedArg(
'_formatLink', key, options[key], expectedType or 'string', true
)
end
check('link')
check('display')
check('target')
check('italicizePage', 'boolean')
check('italicizeSection', 'boolean')
check('categorizeMissing')
-- Normalize link and target and check that at least one is present
if options.link == '' then options.link = nil end
if options.target == '' then options.target = nil end
if not (options.link or options.target) then
return missingArgError('Module:Format link')
end
local parsed = parseLink(options.link)
local display = options.display or parsed.display
local catMissing = options.categorizeMissing
local category = ''
-- Find the display text
if not display then display = formatDisplay(parsed, options) end
-- Handle the target option if present
if options.target then
local parsedTarget = parseLink(options.target)
parsed.link = parsedTarget.link
parsed.page = parsedTarget.page
end
-- Test if page exists if a diagnostic category is specified
if catMissing and (mw.ustring.len(catMissing) > 0) then
local title = nil
if parsed.page then title = mw.title.new(parsed.page) end
if title and (not title.isExternal) then
local success, exists = pcall(function() return title.exists end)
if success and not exists then
category = mw.ustring.format('[[Category:%s]]', catMissing)
end
end
end
-- Format the result as a link
if parsed.link == display then
return mw.ustring.format('[[:%s]]%s', parsed.link, category)
else
return mw.ustring.format('[[:%s|%s]]%s', parsed.link, display, category)
end
end
--------------------------------------------------------------------------------
-- Derived convenience functions
--------------------------------------------------------------------------------
function p.formatPages(options, pages)
-- Formats an array of pages using formatLink and the given options table,
-- and returns it as an array. Nil values are not allowed.
local ret = {}
for i, page in ipairs(pages) do
ret[i] = p._formatLink{
link = page,
categorizeMissing = options.categorizeMissing,
italicizePage = options.italicizePage,
italicizeSection = options.italicizeSection
}
end
return ret
end
return p
1253bdd2683ee4badc33856bfd5499b09a7dca1f
Module:Protection banner
828
40
83
2022-10-21T08:07:11Z
Template>WOSlinker
0
use require('strict') instead of require('Module:No globals')
Scribunto
text/plain
-- This module implements {{pp-meta}} and its daughter templates such as
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.
-- Initialise necessary modules.
require('strict')
local makeFileLink = require('Module:File link')._main
local effectiveProtectionLevel = require('Module:Effective protection level')._main
local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main
local yesno = require('Module:Yesno')
-- Lazily initialise modules and objects we don't always need.
local getArgs, makeMessageBox, lang
-- Set constants.
local CONFIG_MODULE = 'Module:Protection banner/config'
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function makeCategoryLink(cat, sort)
if cat then
return string.format(
'[[%s:%s|%s]]',
mw.site.namespaces[14].name,
cat,
sort
)
end
end
-- Validation function for the expiry and the protection date
local function validateDate(dateString, dateType)
if not lang then
lang = mw.language.getContentLanguage()
end
local success, result = pcall(lang.formatDate, lang, 'U', dateString)
if success then
result = tonumber(result)
if result then
return result
end
end
error(string.format(
'invalid %s: %s',
dateType,
tostring(dateString)
), 4)
end
local function makeFullUrl(page, query, display)
return string.format(
'[%s %s]',
tostring(mw.uri.fullUrl(page, query)),
display
)
end
-- Given a directed graph formatted as node -> table of direct successors,
-- get a table of all nodes reachable from a given node (though always
-- including the given node).
local function getReachableNodes(graph, start)
local toWalk, retval = {[start] = true}, {}
while true do
-- Can't use pairs() since we're adding and removing things as we're iterating
local k = next(toWalk) -- This always gets the "first" key
if k == nil then
return retval
end
toWalk[k] = nil
retval[k] = true
for _,v in ipairs(graph[k]) do
if not retval[v] then
toWalk[v] = true
end
end
end
end
--------------------------------------------------------------------------------
-- Protection class
--------------------------------------------------------------------------------
local Protection = {}
Protection.__index = Protection
Protection.supportedActions = {
edit = true,
move = true,
autoreview = true,
upload = true
}
Protection.bannerConfigFields = {
'text',
'explanation',
'tooltip',
'alt',
'link',
'image'
}
function Protection.new(args, cfg, title)
local obj = {}
obj._cfg = cfg
obj.title = title or mw.title.getCurrentTitle()
-- Set action
if not args.action then
obj.action = 'edit'
elseif Protection.supportedActions[args.action] then
obj.action = args.action
else
error(string.format(
'invalid action: %s',
tostring(args.action)
), 3)
end
-- Set level
obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title)
if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then
-- Users need to be autoconfirmed to move pages anyway, so treat
-- semi-move-protected pages as unprotected.
obj.level = '*'
end
-- Set expiry
local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)
if effectiveExpiry == 'infinity' then
obj.expiry = 'indef'
elseif effectiveExpiry ~= 'unknown' then
obj.expiry = validateDate(effectiveExpiry, 'expiry date')
end
-- Set reason
if args[1] then
obj.reason = mw.ustring.lower(args[1])
if obj.reason:find('|') then
error('reasons cannot contain the pipe character ("|")', 3)
end
end
-- Set protection date
if args.date then
obj.protectionDate = validateDate(args.date, 'protection date')
end
-- Set banner config
do
obj.bannerConfig = {}
local configTables = {}
if cfg.banners[obj.action] then
configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason]
end
if cfg.defaultBanners[obj.action] then
configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level]
configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default
end
configTables[#configTables + 1] = cfg.masterBanner
for i, field in ipairs(Protection.bannerConfigFields) do
for j, t in ipairs(configTables) do
if t[field] then
obj.bannerConfig[field] = t[field]
break
end
end
end
end
return setmetatable(obj, Protection)
end
function Protection:isUserScript()
-- Whether the page is a user JavaScript or CSS page.
local title = self.title
return title.namespace == 2 and (
title.contentModel == 'javascript' or title.contentModel == 'css'
)
end
function Protection:isProtected()
return self.level ~= '*'
end
function Protection:shouldShowLock()
-- Whether we should output a banner/padlock
return self:isProtected() and not self:isUserScript()
end
-- Whether this page needs a protection category.
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
function Protection:isTemporary()
return type(self.expiry) == 'number'
end
function Protection:makeProtectionCategory()
if not self:shouldHaveProtectionCategory() then
return ''
end
local cfg = self._cfg
local title = self.title
-- Get the expiry key fragment.
local expiryFragment
if self.expiry == 'indef' then
expiryFragment = self.expiry
elseif type(self.expiry) == 'number' then
expiryFragment = 'temp'
end
-- Get the namespace key fragment.
local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]
if not namespaceFragment and title.namespace % 2 == 1 then
namespaceFragment = 'talk'
end
-- Define the order that key fragments are tested in. This is done with an
-- array of tables containing the value to be tested, along with its
-- position in the cfg.protectionCategories table.
local order = {
{val = expiryFragment, keypos = 1},
{val = namespaceFragment, keypos = 2},
{val = self.reason, keypos = 3},
{val = self.level, keypos = 4},
{val = self.action, keypos = 5}
}
--[[
-- The old protection templates used an ad-hoc protection category system,
-- with some templates prioritising namespaces in their categories, and
-- others prioritising the protection reason. To emulate this in this module
-- we use the config table cfg.reasonsWithNamespacePriority to set the
-- reasons for which namespaces have priority over protection reason.
-- If we are dealing with one of those reasons, move the namespace table to
-- the end of the order table, i.e. give it highest priority. If not, the
-- reason should have highest priority, so move that to the end of the table
-- instead.
--]]
table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))
--[[
-- Define the attempt order. Inactive subtables (subtables with nil "value"
-- fields) are moved to the end, where they will later be given the key
-- "all". This is to cut down on the number of table lookups in
-- cfg.protectionCategories, which grows exponentially with the number of
-- non-nil keys. We keep track of the number of active subtables with the
-- noActive parameter.
--]]
local noActive, attemptOrder
do
local active, inactive = {}, {}
for i, t in ipairs(order) do
if t.val then
active[#active + 1] = t
else
inactive[#inactive + 1] = t
end
end
noActive = #active
attemptOrder = active
for i, t in ipairs(inactive) do
attemptOrder[#attemptOrder + 1] = t
end
end
--[[
-- Check increasingly generic key combinations until we find a match. If a
-- specific category exists for the combination of key fragments we are
-- given, that match will be found first. If not, we keep trying different
-- key fragment combinations until we match using the key
-- "all-all-all-all-all".
--
-- To generate the keys, we index the key subtables using a binary matrix
-- with indexes i and j. j is only calculated up to the number of active
-- subtables. For example, if there were three active subtables, the matrix
-- would look like this, with 0 corresponding to the key fragment "all", and
-- 1 corresponding to other key fragments.
--
-- j 1 2 3
-- i
-- 1 1 1 1
-- 2 0 1 1
-- 3 1 0 1
-- 4 0 0 1
-- 5 1 1 0
-- 6 0 1 0
-- 7 1 0 0
-- 8 0 0 0
--
-- Values of j higher than the number of active subtables are set
-- to the string "all".
--
-- A key for cfg.protectionCategories is constructed for each value of i.
-- The position of the value in the key is determined by the keypos field in
-- each subtable.
--]]
local cats = cfg.protectionCategories
for i = 1, 2^noActive do
local key = {}
for j, t in ipairs(attemptOrder) do
if j > noActive then
key[t.keypos] = 'all'
else
local quotient = i / 2 ^ (j - 1)
quotient = math.ceil(quotient)
if quotient % 2 == 1 then
key[t.keypos] = t.val
else
key[t.keypos] = 'all'
end
end
end
key = table.concat(key, '|')
local attempt = cats[key]
if attempt then
return makeCategoryLink(attempt, title.text)
end
end
return ''
end
function Protection:isIncorrect()
local expiry = self.expiry
return not self:shouldHaveProtectionCategory()
or type(expiry) == 'number' and expiry < os.time()
end
function Protection:isTemplateProtectedNonTemplate()
local action, namespace = self.action, self.title.namespace
return self.level == 'templateeditor'
and (
(action ~= 'edit' and action ~= 'move')
or (namespace ~= 10 and namespace ~= 828)
)
end
function Protection:makeCategoryLinks()
local msg = self._cfg.msg
local ret = {self:makeProtectionCategory()}
if self:isIncorrect() then
ret[#ret + 1] = makeCategoryLink(
msg['tracking-category-incorrect'],
self.title.text
)
end
if self:isTemplateProtectedNonTemplate() then
ret[#ret + 1] = makeCategoryLink(
msg['tracking-category-template'],
self.title.text
)
end
return table.concat(ret)
end
--------------------------------------------------------------------------------
-- Blurb class
--------------------------------------------------------------------------------
local Blurb = {}
Blurb.__index = Blurb
Blurb.bannerTextFields = {
text = true,
explanation = true,
tooltip = true,
alt = true,
link = true
}
function Blurb.new(protectionObj, args, cfg)
return setmetatable({
_cfg = cfg,
_protectionObj = protectionObj,
_args = args
}, Blurb)
end
-- Private methods --
function Blurb:_formatDate(num)
-- Formats a Unix timestamp into dd Month, YYYY format.
lang = lang or mw.language.getContentLanguage()
local success, date = pcall(
lang.formatDate,
lang,
self._cfg.msg['expiry-date-format'] or 'j F Y',
'@' .. tostring(num)
)
if success then
return date
end
end
function Blurb:_getExpandedMessage(msgKey)
return self:_substituteParameters(self._cfg.msg[msgKey])
end
function Blurb:_substituteParameters(msg)
if not self._params then
local parameterFuncs = {}
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter
parameterFuncs.EXPIRY = self._makeExpiryParameter
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter
parameterFuncs.IMAGELINK = self._makeImageLinkParameter
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter
parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter
parameterFuncs.PAGETYPE = self._makePagetypeParameter
parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
parameterFuncs.TALKPAGE = self._makeTalkPageParameter
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter
parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter
parameterFuncs.VANDAL = self._makeVandalTemplateParameter
self._params = setmetatable({}, {
__index = function (t, k)
local param
if parameterFuncs[k] then
param = parameterFuncs[k](self)
end
param = param or ''
t[k] = param
return param
end
})
end
msg = msg:gsub('${(%u+)}', self._params)
return msg
end
function Blurb:_makeCurrentVersionParameter()
-- A link to the page history or the move log, depending on the kind of
-- protection.
local pagename = self._protectionObj.title.prefixedText
if self._protectionObj.action == 'move' then
-- We need the move log link.
return makeFullUrl(
'Special:Log',
{type = 'move', page = pagename},
self:_getExpandedMessage('current-version-move-display')
)
else
-- We need the history link.
return makeFullUrl(
pagename,
{action = 'history'},
self:_getExpandedMessage('current-version-edit-display')
)
end
end
function Blurb:_makeEditRequestParameter()
local mEditRequest = require('Module:Submit an edit request')
local action = self._protectionObj.action
local level = self._protectionObj.level
-- Get the edit request type.
local requestType
if action == 'edit' then
if level == 'autoconfirmed' then
requestType = 'semi'
elseif level == 'extendedconfirmed' then
requestType = 'extended'
elseif level == 'templateeditor' then
requestType = 'template'
end
end
requestType = requestType or 'full'
-- Get the display value.
local display = self:_getExpandedMessage('edit-request-display')
return mEditRequest._link{type = requestType, display = display}
end
function Blurb:_makeExpiryParameter()
local expiry = self._protectionObj.expiry
if type(expiry) == 'number' then
return self:_formatDate(expiry)
else
return expiry
end
end
function Blurb:_makeExplanationBlurbParameter()
-- Cover special cases first.
if self._protectionObj.title.namespace == 8 then
-- MediaWiki namespace
return self:_getExpandedMessage('explanation-blurb-nounprotect')
end
-- Get explanation blurb table keys
local action = self._protectionObj.action
local level = self._protectionObj.level
local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject'
-- Find the message in the explanation blurb table and substitute any
-- parameters.
local explanations = self._cfg.explanationBlurbs
local msg
if explanations[action][level] and explanations[action][level][talkKey] then
msg = explanations[action][level][talkKey]
elseif explanations[action][level] and explanations[action][level].default then
msg = explanations[action][level].default
elseif explanations[action].default and explanations[action].default[talkKey] then
msg = explanations[action].default[talkKey]
elseif explanations[action].default and explanations[action].default.default then
msg = explanations[action].default.default
else
error(string.format(
'could not find explanation blurb for action "%s", level "%s" and talk key "%s"',
action,
level,
talkKey
), 8)
end
return self:_substituteParameters(msg)
end
function Blurb:_makeImageLinkParameter()
local imageLinks = self._cfg.imageLinks
local action = self._protectionObj.action
local level = self._protectionObj.level
local msg
if imageLinks[action][level] then
msg = imageLinks[action][level]
elseif imageLinks[action].default then
msg = imageLinks[action].default
else
msg = imageLinks.edit.default
end
return self:_substituteParameters(msg)
end
function Blurb:_makeIntroBlurbParameter()
if self._protectionObj:isTemporary() then
return self:_getExpandedMessage('intro-blurb-expiry')
else
return self:_getExpandedMessage('intro-blurb-noexpiry')
end
end
function Blurb:_makeIntroFragmentParameter()
if self._protectionObj:isTemporary() then
return self:_getExpandedMessage('intro-fragment-expiry')
else
return self:_getExpandedMessage('intro-fragment-noexpiry')
end
end
function Blurb:_makePagetypeParameter()
local pagetypes = self._cfg.pagetypes
return pagetypes[self._protectionObj.title.namespace]
or pagetypes.default
or error('no default pagetype defined', 8)
end
function Blurb:_makeProtectionBlurbParameter()
local protectionBlurbs = self._cfg.protectionBlurbs
local action = self._protectionObj.action
local level = self._protectionObj.level
local msg
if protectionBlurbs[action][level] then
msg = protectionBlurbs[action][level]
elseif protectionBlurbs[action].default then
msg = protectionBlurbs[action].default
elseif protectionBlurbs.edit.default then
msg = protectionBlurbs.edit.default
else
error('no protection blurb defined for protectionBlurbs.edit.default', 8)
end
return self:_substituteParameters(msg)
end
function Blurb:_makeProtectionDateParameter()
local protectionDate = self._protectionObj.protectionDate
if type(protectionDate) == 'number' then
return self:_formatDate(protectionDate)
else
return protectionDate
end
end
function Blurb:_makeProtectionLevelParameter()
local protectionLevels = self._cfg.protectionLevels
local action = self._protectionObj.action
local level = self._protectionObj.level
local msg
if protectionLevels[action][level] then
msg = protectionLevels[action][level]
elseif protectionLevels[action].default then
msg = protectionLevels[action].default
elseif protectionLevels.edit.default then
msg = protectionLevels.edit.default
else
error('no protection level defined for protectionLevels.edit.default', 8)
end
return self:_substituteParameters(msg)
end
function Blurb:_makeProtectionLogParameter()
local pagename = self._protectionObj.title.prefixedText
if self._protectionObj.action == 'autoreview' then
-- We need the pending changes log.
return makeFullUrl(
'Special:Log',
{type = 'stable', page = pagename},
self:_getExpandedMessage('pc-log-display')
)
else
-- We need the protection log.
return makeFullUrl(
'Special:Log',
{type = 'protect', page = pagename},
self:_getExpandedMessage('protection-log-display')
)
end
end
function Blurb:_makeTalkPageParameter()
return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._protectionObj.title.namespace].talk.name,
self._protectionObj.title.text,
self._args.section or 'top',
self:_getExpandedMessage('talk-page-link-display')
)
end
function Blurb:_makeTooltipBlurbParameter()
if self._protectionObj:isTemporary() then
return self:_getExpandedMessage('tooltip-blurb-expiry')
else
return self:_getExpandedMessage('tooltip-blurb-noexpiry')
end
end
function Blurb:_makeTooltipFragmentParameter()
if self._protectionObj:isTemporary() then
return self:_getExpandedMessage('tooltip-fragment-expiry')
else
return self:_getExpandedMessage('tooltip-fragment-noexpiry')
end
end
function Blurb:_makeVandalTemplateParameter()
return mw.getCurrentFrame():expandTemplate{
title="vandal-m",
args={self._args.user or self._protectionObj.title.baseText}
}
end
-- Public methods --
function Blurb:makeBannerText(key)
-- Validate input.
if not key or not Blurb.bannerTextFields[key] then
error(string.format(
'"%s" is not a valid banner config field',
tostring(key)
), 2)
end
-- Generate the text.
local msg = self._protectionObj.bannerConfig[key]
if type(msg) == 'string' then
return self:_substituteParameters(msg)
elseif type(msg) == 'function' then
msg = msg(self._protectionObj, self._args)
if type(msg) ~= 'string' then
error(string.format(
'bad output from banner config function with key "%s"'
.. ' (expected string, got %s)',
tostring(key),
type(msg)
), 4)
end
return self:_substituteParameters(msg)
end
end
--------------------------------------------------------------------------------
-- BannerTemplate class
--------------------------------------------------------------------------------
local BannerTemplate = {}
BannerTemplate.__index = BannerTemplate
function BannerTemplate.new(protectionObj, cfg)
local obj = {}
obj._cfg = cfg
-- Set the image filename.
local imageFilename = protectionObj.bannerConfig.image
if imageFilename then
obj._imageFilename = imageFilename
else
-- If an image filename isn't specified explicitly in the banner config,
-- generate it from the protection status and the namespace.
local action = protectionObj.action
local level = protectionObj.level
local namespace = protectionObj.title.namespace
local reason = protectionObj.reason
-- Deal with special cases first.
if (
namespace == 10
or namespace == 828
or reason and obj._cfg.indefImageReasons[reason]
)
and action == 'edit'
and level == 'sysop'
and not protectionObj:isTemporary()
then
-- Fully protected modules and templates get the special red "indef"
-- padlock.
obj._imageFilename = obj._cfg.msg['image-filename-indef']
else
-- Deal with regular protection types.
local images = obj._cfg.images
if images[action] then
if images[action][level] then
obj._imageFilename = images[action][level]
elseif images[action].default then
obj._imageFilename = images[action].default
end
end
end
end
return setmetatable(obj, BannerTemplate)
end
function BannerTemplate:renderImage()
local filename = self._imageFilename
or self._cfg.msg['image-filename-default']
or 'Transparent.gif'
return makeFileLink{
file = filename,
size = (self.imageWidth or 20) .. 'px',
alt = self._imageAlt,
link = self._imageLink,
caption = self.imageCaption
}
end
--------------------------------------------------------------------------------
-- Banner class
--------------------------------------------------------------------------------
local Banner = setmetatable({}, BannerTemplate)
Banner.__index = Banner
function Banner.new(protectionObj, blurbObj, cfg)
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
obj.imageWidth = 40
obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip.
obj._reasonText = blurbObj:makeBannerText('text')
obj._explanationText = blurbObj:makeBannerText('explanation')
obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing.
return setmetatable(obj, Banner)
end
function Banner:__tostring()
-- Renders the banner.
makeMessageBox = makeMessageBox or require('Module:Message box').main
local reasonText = self._reasonText or error('no reason text set', 2)
local explanationText = self._explanationText
local mbargs = {
page = self._page,
type = 'protection',
image = self:renderImage(),
text = string.format(
"'''%s'''%s",
reasonText,
explanationText and '<br />' .. explanationText or ''
)
}
return makeMessageBox('mbox', mbargs)
end
--------------------------------------------------------------------------------
-- Padlock class
--------------------------------------------------------------------------------
local Padlock = setmetatable({}, BannerTemplate)
Padlock.__index = Padlock
function Padlock.new(protectionObj, blurbObj, cfg)
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
obj.imageWidth = 20
obj.imageCaption = blurbObj:makeBannerText('tooltip')
obj._imageAlt = blurbObj:makeBannerText('alt')
obj._imageLink = blurbObj:makeBannerText('link')
obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action]
or cfg.padlockIndicatorNames.default
or 'pp-default'
return setmetatable(obj, Padlock)
end
function Padlock:__tostring()
local frame = mw.getCurrentFrame()
-- The nowiki tag helps prevent whitespace at the top of articles.
return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{
name = 'indicator',
args = {name = self._indicatorName},
content = self:renderImage()
}
end
--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------
local p = {}
function p._exportClasses()
-- This is used for testing purposes.
return {
Protection = Protection,
Blurb = Blurb,
BannerTemplate = BannerTemplate,
Banner = Banner,
Padlock = Padlock,
}
end
function p._main(args, cfg, title)
args = args or {}
cfg = cfg or require(CONFIG_MODULE)
local protectionObj = Protection.new(args, cfg, title)
local ret = {}
-- If a page's edit protection is equally or more restrictive than its
-- protection from some other action, then don't bother displaying anything
-- for the other action (except categories).
if not yesno(args.catonly) and (protectionObj.action == 'edit' or
args.demolevel or
not getReachableNodes(
cfg.hierarchy,
protectionObj.level
)[effectiveProtectionLevel('edit', protectionObj.title)])
then
-- Initialise the blurb object
local blurbObj = Blurb.new(protectionObj, args, cfg)
-- Render the banner
if protectionObj:shouldShowLock() then
ret[#ret + 1] = tostring(
(yesno(args.small) and Padlock or Banner)
.new(protectionObj, blurbObj, cfg)
)
end
end
-- Render the categories
if yesno(args.category) ~= false then
ret[#ret + 1] = protectionObj:makeCategoryLinks()
end
return table.concat(ret)
end
function p.main(frame, cfg)
cfg = cfg or require(CONFIG_MODULE)
-- Find default args, if any.
local parent = frame.getParent and frame:getParent()
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')]
-- Find user args, and use the parent frame if we are being called from a
-- wrapper template.
getArgs = getArgs or require('Module:Arguments').getArgs
local userArgs = getArgs(frame, {
parentOnly = defaultArgs,
frameOnly = not defaultArgs
})
-- Build the args table. User-specified args overwrite default args.
local args = {}
for k, v in pairs(defaultArgs or {}) do
args[k] = v
end
for k, v in pairs(userArgs) do
args[k] = v
end
return p._main(args, cfg)
end
return p
894f0884d4c2da1ce19d385b96f59af654b0946a
Module:Section link
828
128
259
2022-10-22T09:09:53Z
w>WOSlinker
0
use require('strict') instead of require('Module:No globals')
Scribunto
text/plain
-- This module implements {{section link}}.
require('strict');
local checkType = require('libraryUtil').checkType
local p = {}
local function makeSectionLink(page, section, display)
display = display or section
page = page or ''
-- MediaWiki doesn't allow these in `page`, so only need to do for `section`
if type(section) == 'string' then
section = string.gsub(section, "{", "{")
section = string.gsub(section, "}", "}")
end
return string.format('[[%s#%s|%s]]', page, section, display)
end
local function normalizeTitle(title)
title = mw.ustring.gsub(mw.ustring.gsub(title, "'", ""), '"', '')
title = mw.ustring.gsub(title, "%b<>", "")
return mw.title.new(title).prefixedText
end
function p._main(page, sections, options, title)
-- Validate input.
checkType('_main', 1, page, 'string', true)
checkType('_main', 3, options, 'table', true)
if sections == nil then
sections = {}
elseif type(sections) == 'string' then
sections = {sections}
elseif type(sections) ~= 'table' then
error(string.format(
"type error in argument #2 to '_main' " ..
"(string, table or nil expected, got %s)",
type(sections)
), 2)
end
options = options or {}
title = title or mw.title.getCurrentTitle()
-- Deal with blank page names elegantly
if page and not page:find('%S') then
page = nil
options.nopage = true
end
-- Make the link(s).
local isShowingPage = not options.nopage
if #sections <= 1 then
local linkPage = page or ''
local section = sections[1] or 'Notes'
local display = '§ ' .. section
if isShowingPage then
page = page or title.prefixedText
if options.display and options.display ~= '' then
if normalizeTitle(options.display) == normalizeTitle(page) then
display = options.display .. ' ' .. display
else
error(string.format(
'Display title "%s" was ignored since it is ' ..
"not equivalent to the page's actual title",
options.display
), 0)
end
else
display = page .. ' ' .. display
end
end
return makeSectionLink(linkPage, section, display)
else
-- Multiple sections. First, make a list of the links to display.
local ret = {}
for i, section in ipairs(sections) do
ret[i] = makeSectionLink(page, section)
end
-- Assemble the list of links into a string with mw.text.listToText.
-- We use the default separator for mw.text.listToText, but a custom
-- conjunction. There is also a special case conjunction if we only
-- have two links.
local conjunction
if #sections == 2 then
conjunction = '​ and '
else
conjunction = ', and '
end
ret = mw.text.listToText(ret, nil, conjunction)
-- Add the intro text.
local intro = '§§ '
if isShowingPage then
intro = (page or title.prefixedText) .. ' ' .. intro
end
ret = intro .. ret
return ret
end
end
function p.main(frame)
local yesno = require('Module:Yesno')
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Section link',
valueFunc = function (key, value)
value = value:match('^%s*(.-)%s*$') -- Trim whitespace
-- Allow blank first parameters, as the wikitext template does this.
if value ~= '' or key == 1 then
return value
end
end
})
for k, v in pairs(args) do -- replace underscores in the positional parameter values
if 'number' == type(k) then
if not yesno (args['keep-underscores']) then -- unless |keep-underscores=yes
args[k] = mw.uri.decode (v, 'WIKI'); -- percent-decode; replace underscores with space characters
else
args[k] = mw.uri.decode (v, 'PATH'); -- percent-decode; retain underscores
end
end
end
-- Sort the arguments.
local page
local sections, options = {}, {}
for k, v in pairs(args) do
if k == 1 then
-- Doing this in the loop because of a bug in [[Module:Arguments]]
-- when using pairs with deleted arguments.
page = mw.text.decode(v, true)
elseif type(k) == 'number' then
sections[k] = v
else
options[k] = v
end
end
options.nopage = yesno (options.nopage); -- make boolean
-- Extract section from page, if present
if page then
local p, s = page:match('^(.-)#(.*)$')
if p then page, sections[1] = p, s end
end
-- Compress the sections array.
local function compressArray(t)
local nums, ret = {}, {}
for num in pairs(t) do
nums[#nums + 1] = num
end
table.sort(nums)
for i, num in ipairs(nums) do
ret[i] = t[num]
end
return ret
end
sections = compressArray(sections)
return p._main(page, sections, options)
end
return p
5cc61d43dc601ca43e9472500fc5cd09ca7cea44
Module:YMD to ISO
828
116
235
2022-11-22T10:54:50Z
w>Dinoguy1000
0
simplify month_number (instead of a separate test, `sept` can simply be added as an entry to the months_abbr array)
Scribunto
text/plain
local p = {}
local function month_number(month_name)
local months_full = {january=1, february=2, march=3, april=4, may=5, june=6, july=7, august=8, september=9, october=10, november=11, december=12}
local months_abbr = {jan=1, feb=2, mar=3, apr=4, may=5, jun=6, jul=7, aug=8, sep=9, sept=9, oct=10, nov=11, dec=12}
local month_lc, _ = string.gsub(string.lower(month_name),'%.','',1)
local month_num = months_full[month_lc] or months_abbr[month_lc] or 0
return month_num
end
local function days_in_month(month_num,year)
-- modified from code in Module:Citation/CS1/Date_validation
local days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
local month_length
if month_num == 2 then -- February: 28 days, unless leap year
month_length = 28
if year <= 1582 then -- Julian calendar before Oct 1582
if (year%4) == 0 then
month_length = 29 -- if leap year, then 29 days
end
else -- Gregorian calendar since Oct 1582
if ( (year%4)==0 and ((year%100)~=0 or (year%400)==0) ) then
month_length = 29 -- if leap year, then 29 days
end
end
else -- not February, get number of days for month
month_length = days[month_num]
end
return month_length
end
local function zero_pad(string)
if string.len(string) == 1 then
return '0' .. string
else
return string
end
end
function p.main(frame)
if frame.args[1] == nil then
return '' -- first argument is missing
end
local arg1, _ = string.gsub(mw.text.trim(frame.args[1]),'_',' ')
return p._main(arg1)
end
function p._main(arg1)
if arg1 == '' then
return '' -- first argument is empty
end
if not arg1:match('^%d%d%d%d %a%a%a%a?%.?%a?%a?%a?%a?%a?%a? *%d%d?$') then
return arg1 -- invalid date pattern
end
local year, month_name, day = string.match(arg1, '^(%d%d%d%d) *(%a%a%a%a?%.?%a?%a?%a?%a?%a?%a?) *(%d%d?)$')
if month_number(month_name) == 0 then
return arg1 -- invalid month name or abbreviation
end
if tonumber(day) < 1 or tonumber(day) > days_in_month(month_number(month_name),tonumber(year)) then
return arg1 -- invalid day number for given month
end
return year .. '-' .. zero_pad(tostring(month_number(month_name))) .. '-' .. zero_pad(day)
end
return p
a9f87bfe223afec859d2f3de909e6682d2334db4
Template:Suppress categories
10
68
139
2022-11-26T18:00:01Z
Template>MusikBot II
0
Changed protection settings for "[[Template:Suppress categories]]": [[Wikipedia:High-risk templates|High-risk template or module]]: 2612 transclusions ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Require extended confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite))
wikitext
text/x-wiki
<includeonly>{{{{{|safesubst:}}}#invoke:Suppress categories|main}}</includeonly><noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
1f9c6065201d31d4c70f982129b5babbb809ae8c
Template:Plainlist/styles.css
10
84
171
2022-12-11T06:59:53Z
Template>Izno
0
add this reset from mobile.css
text
text/plain
/* {{pp-template|small=yes}} */
.plainlist ol,
.plainlist ul {
line-height: inherit;
list-style: none;
margin: 0;
padding: 0; /* Reset Minerva default */
}
.plainlist ol li,
.plainlist ul li {
margin-bottom: 0;
}
51706efa229ff8794c0d94f260a208e7c5e6ec30
Module:Shortcut
828
134
271
2022-12-13T23:41:34Z
w>Izno
0
use module:list for plainlist, move templatestyles to module space
Scribunto
text/plain
-- This module implements {{shortcut}}.
-- Set constants
local CONFIG_MODULE = 'Module:Shortcut/config'
-- Load required modules
local checkType = require('libraryUtil').checkType
local yesno = require('Module:Yesno')
local p = {}
local function message(msg, ...)
return mw.message.newRawMessage(msg, ...):plain()
end
local function makeCategoryLink(cat)
return string.format('[[%s:%s]]', mw.site.namespaces[14].name, cat)
end
function p._main(shortcuts, options, frame, cfg)
checkType('_main', 1, shortcuts, 'table')
checkType('_main', 2, options, 'table', true)
options = options or {}
frame = frame or mw.getCurrentFrame()
cfg = cfg or mw.loadData(CONFIG_MODULE)
local templateMode = options.template and yesno(options.template)
local redirectMode = options.redirect and yesno(options.redirect)
local isCategorized = not options.category or yesno(options.category) ~= false
-- Validate shortcuts
for i, shortcut in ipairs(shortcuts) do
if type(shortcut) ~= 'string' or #shortcut < 1 then
error(message(cfg['invalid-shortcut-error'], i), 2)
end
end
-- Make the list items. These are the shortcuts plus any extra lines such
-- as options.msg.
local listItems = {}
for i, shortcut in ipairs(shortcuts) do
local templatePath, prefix
if templateMode then
-- Namespace detection
local titleObj = mw.title.new(shortcut, 10)
if titleObj.namespace == 10 then
templatePath = titleObj.fullText
else
templatePath = shortcut
end
prefix = options['pre' .. i] or options.pre or ''
end
if options.target and yesno(options.target) then
listItems[i] = templateMode
and string.format("{{%s[[%s|%s]]}}", prefix, templatePath, shortcut)
or string.format("[[%s]]", shortcut)
else
listItems[i] = frame:expandTemplate{
title = 'No redirect',
args = templateMode and {templatePath, shortcut} or {shortcut, shortcut}
}
if templateMode then
listItems[i] = string.format("{{%s%s}}", prefix, listItems[i])
end
end
end
table.insert(listItems, options.msg)
-- Return an error if we have nothing to display
if #listItems < 1 then
local msg = cfg['no-content-error']
msg = string.format('<strong class="error">%s</strong>', msg)
if isCategorized and cfg['no-content-error-category'] then
msg = msg .. makeCategoryLink(cfg['no-content-error-category'])
end
return msg
end
local root = mw.html.create()
root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = 'Module:Shortcut/styles.css'} })
-- Anchors
local anchorDiv = root
:tag('div')
:addClass('module-shortcutanchordiv')
for i, shortcut in ipairs(shortcuts) do
local anchor = mw.uri.anchorEncode(shortcut)
anchorDiv:tag('span'):attr('id', anchor)
end
-- Shortcut heading
local shortcutHeading
do
local nShortcuts = #shortcuts
if nShortcuts > 0 then
local headingMsg = options['shortcut-heading'] or
redirectMode and cfg['redirect-heading'] or
cfg['shortcut-heading']
shortcutHeading = message(headingMsg, nShortcuts)
shortcutHeading = frame:preprocess(shortcutHeading)
end
end
-- Shortcut box
local shortcutList = root
:tag('div')
:addClass('module-shortcutboxplain noprint')
:attr('role', 'note')
if options.float and options.float:lower() == 'left' then
shortcutList:addClass('module-shortcutboxleft')
end
if options.clear and options.clear ~= '' then
shortcutList:css('clear', options.clear)
end
if shortcutHeading then
shortcutList
:tag('div')
:addClass('module-shortcutlist')
:wikitext(shortcutHeading)
end
local ubl = require('Module:List').unbulleted(listItems)
shortcutList:wikitext(ubl)
return tostring(root)
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
-- Separate shortcuts from options
local shortcuts, options = {}, {}
for k, v in pairs(args) do
if type(k) == 'number' then
shortcuts[k] = v
else
options[k] = v
end
end
-- Compress the shortcut array, which may contain nils.
local function compressArray(t)
local nums, ret = {}, {}
for k in pairs(t) do
nums[#nums + 1] = k
end
table.sort(nums)
for i, num in ipairs(nums) do
ret[i] = t[num]
end
return ret
end
shortcuts = compressArray(shortcuts)
return p._main(shortcuts, options, frame)
end
return p
03fd46a265e549852a9ed3d3a9249b247d84cb4f
Template:Mbox
10
87
177
2022-12-18T05:46:16Z
w>TadejM
0
wikitext
text/x-wiki
{{#invoke:Message box|mbox}}<noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! -->
</noinclude>
5bfb2becf8bed35974b47e3ff8660dc14bee40c7
Template:Hlist/styles.css
10
74
151
2022-12-26T18:00:17Z
Template>Izno
0
actually remove that block, someone can dig for authorship
text
text/plain
/* {{pp-protected|reason=match parent|small=yes}} */
/*
* hlist styles are defined in core and Minerva and differ in Minerva. The
* current definitions here (2023-01-01) are sufficient to override Minerva
* without use of the hlist-separated class. The most problematic styles were
* related to margin, padding, and the bullet. Check files listed at
* [[MediaWiki talk:Common.css/to do#hlist-separated]]
*/
/*
* TODO: When the majority of readership supports it (or some beautiful world
* in which grade C support is above the minimum threshold), use :is()
*/
.hlist dl,
.hlist ol,
.hlist ul {
margin: 0;
padding: 0;
}
/* Display list items inline */
.hlist dd,
.hlist dt,
.hlist li {
/*
* don't trust the note that says margin doesn't work with inline
* removing margin: 0 makes dds have margins again
* We also want to reset margin-right in Minerva
*/
margin: 0;
display: inline;
}
/* Display requested top-level lists inline */
.hlist.inline,
.hlist.inline dl,
.hlist.inline ol,
.hlist.inline ul,
/* Display nested lists inline */
.hlist dl dl,
.hlist dl ol,
.hlist dl ul,
.hlist ol dl,
.hlist ol ol,
.hlist ol ul,
.hlist ul dl,
.hlist ul ol,
.hlist ul ul {
display: inline;
}
/* Hide empty list items */
.hlist .mw-empty-li {
display: none;
}
/* TODO: :not() can maybe be used here to remove the later rule. naive test
* seems to work. more testing needed. like so:
*.hlist dt:not(:last-child)::after {
* content: ": ";
*}
*.hlist dd:not(:last-child)::after,
*.hlist li:not(:last-child)::after {
* content: " · ";
* font-weight: bold;
*}
*/
/* Generate interpuncts */
.hlist dt::after {
content: ": ";
}
.hlist dd::after,
.hlist li::after {
content: " · ";
font-weight: bold;
}
.hlist dd:last-child::after,
.hlist dt:last-child::after,
.hlist li:last-child::after {
content: none;
}
/* Add parentheses around nested lists */
.hlist dd dd:first-child::before,
.hlist dd dt:first-child::before,
.hlist dd li:first-child::before,
.hlist dt dd:first-child::before,
.hlist dt dt:first-child::before,
.hlist dt li:first-child::before,
.hlist li dd:first-child::before,
.hlist li dt:first-child::before,
.hlist li li:first-child::before {
content: " (";
font-weight: normal;
}
.hlist dd dd:last-child::after,
.hlist dd dt:last-child::after,
.hlist dd li:last-child::after,
.hlist dt dd:last-child::after,
.hlist dt dt:last-child::after,
.hlist dt li:last-child::after,
.hlist li dd:last-child::after,
.hlist li dt:last-child::after,
.hlist li li:last-child::after {
content: ")";
font-weight: normal;
}
/* Put ordinals in front of ordered list items */
.hlist ol {
counter-reset: listitem;
}
.hlist ol > li {
counter-increment: listitem;
}
.hlist ol > li::before {
content: " " counter(listitem) "\a0";
}
.hlist dd ol > li:first-child::before,
.hlist dt ol > li:first-child::before,
.hlist li ol > li:first-child::before {
content: " (" counter(listitem) "\a0";
}
8c9dd9c9c00f30eead17fe10f51d183333e81f33
Module:Infobox
828
6
15
2022-12-27T21:29:12Z
Template>Izno
0
merge hlist here
Scribunto
text/plain
local p = {}
local args = {}
local origArgs = {}
local root
local empty_row_categories = {}
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local has_rows = false
local lists = {
plainlist_t = {
patterns = {
'^plainlist$',
'%splainlist$',
'^plainlist%s',
'%splainlist%s'
},
found = false,
styles = 'Plainlist/styles.css'
},
hlist_t = {
patterns = {
'^hlist$',
'%shlist$',
'^hlist%s',
'%shlist%s'
},
found = false,
styles = 'Hlist/styles.css'
}
}
local function has_list_class(args_to_check)
for _, list in pairs(lists) do
if not list.found then
for _, arg in pairs(args_to_check) do
for _, pattern in ipairs(list.patterns) do
if mw.ustring.find(arg or '', pattern) then
list.found = true
break
end
end
if list.found then break end
end
end
end
end
local function fixChildBoxes(sval, tt)
local function notempty( s ) return s and s:match( '%S' ) end
if notempty(sval) then
local marker = '<span class=special_infobox_marker>'
local s = sval
-- start moving templatestyles and categories inside of table rows
local slast = ''
while slast ~= s do
slast = s
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*%]%])', '%2%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)', '%2%1')
end
-- end moving templatestyles and categories inside of table rows
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
if s:match(marker) then
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1')
end
if s:match(marker) then
local subcells = mw.text.split(s, marker)
s = ''
for k = 1, #subcells do
if k == 1 then
s = s .. subcells[k] .. '</' .. tt .. '></tr>'
elseif k == #subcells then
local rowstyle = ' style="display:none"'
if notempty(subcells[k]) then rowstyle = '' end
s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' ..
subcells[k]
elseif notempty(subcells[k]) then
if (k % 2) == 0 then
s = s .. subcells[k]
else
s = s .. '<tr><' .. tt .. ' colspan=2>\n' ..
subcells[k] .. '</' .. tt .. '></tr>'
end
end
end
end
-- the next two lines add a newline at the end of lists for the PHP parser
-- [[Special:Diff/849054481]]
-- remove when [[:phab:T191516]] is fixed or OBE
s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')
s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')
return s
else
return sval
end
end
-- Cleans empty tables
local function cleanInfobox()
root = tostring(root)
if has_rows == false then
root = mw.ustring.gsub(root, '<table[^<>]*>%s*</table>', '')
end
end
-- Returns the union of the values of two tables, as a sequence.
local function union(t1, t2)
local vals = {}
for k, v in pairs(t1) do
vals[v] = true
end
for k, v in pairs(t2) do
vals[v] = true
end
local ret = {}
for k, v in pairs(vals) do
table.insert(ret, k)
end
return ret
end
-- Returns a table containing the numbers of the arguments that exist
-- for the specified prefix. For example, if the prefix was 'data', and
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
local function getArgNums(prefix)
local nums = {}
for k, v in pairs(args) do
local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
if num then table.insert(nums, tonumber(num)) end
end
table.sort(nums)
return nums
end
-- Adds a row to the infobox, with either a header cell
-- or a label/data cell combination.
local function addRow(rowArgs)
if rowArgs.header and rowArgs.header ~= '_BLANK_' then
has_rows = true
has_list_class({ rowArgs.rowclass, rowArgs.class, args.headerclass })
root
:tag('tr')
:addClass(rowArgs.rowclass)
:cssText(rowArgs.rowstyle)
:tag('th')
:attr('colspan', '2')
:addClass('infobox-header')
:addClass(rowArgs.class)
:addClass(args.headerclass)
-- @deprecated next; target .infobox-<name> .infobox-header
:cssText(args.headerstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.header, 'th'))
if rowArgs.data then
root:wikitext(
'[[Category:Pages using infobox templates with ignored data cells]]'
)
end
elseif rowArgs.data and rowArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ rowArgs.rowclass, rowArgs.class })
local row = root:tag('tr')
row:addClass(rowArgs.rowclass)
row:cssText(rowArgs.rowstyle)
if rowArgs.label then
row
:tag('th')
:attr('scope', 'row')
:addClass('infobox-label')
-- @deprecated next; target .infobox-<name> .infobox-label
:cssText(args.labelstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(rowArgs.label)
:done()
end
local dataCell = row:tag('td')
dataCell
:attr('colspan', not rowArgs.label and '2' or nil)
:addClass(not rowArgs.label and 'infobox-full-data' or 'infobox-data')
:addClass(rowArgs.class)
-- @deprecated next; target .infobox-<name> .infobox(-full)-data
:cssText(rowArgs.datastyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.data, 'td'))
else
table.insert(empty_row_categories, rowArgs.data or '')
end
end
local function renderTitle()
if not args.title then return end
has_rows = true
has_list_class({args.titleclass})
root
:tag('caption')
:addClass('infobox-title')
:addClass(args.titleclass)
-- @deprecated next; target .infobox-<name> .infobox-title
:cssText(args.titlestyle)
:wikitext(args.title)
end
local function renderAboveRow()
if not args.above then return end
has_rows = true
has_list_class({ args.aboveclass })
root
:tag('tr')
:tag('th')
:attr('colspan', '2')
:addClass('infobox-above')
:addClass(args.aboveclass)
-- @deprecated next; target .infobox-<name> .infobox-above
:cssText(args.abovestyle)
:wikitext(fixChildBoxes(args.above,'th'))
end
local function renderBelowRow()
if not args.below then return end
has_rows = true
has_list_class({ args.belowclass })
root
:tag('tr')
:tag('td')
:attr('colspan', '2')
:addClass('infobox-below')
:addClass(args.belowclass)
-- @deprecated next; target .infobox-<name> .infobox-below
:cssText(args.belowstyle)
:wikitext(fixChildBoxes(args.below,'td'))
end
local function addSubheaderRow(subheaderArgs)
if subheaderArgs.data and
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ subheaderArgs.rowclass, subheaderArgs.class })
local row = root:tag('tr')
row:addClass(subheaderArgs.rowclass)
local dataCell = row:tag('td')
dataCell
:attr('colspan', '2')
:addClass('infobox-subheader')
:addClass(subheaderArgs.class)
:cssText(subheaderArgs.datastyle)
:cssText(subheaderArgs.rowcellstyle)
:wikitext(fixChildBoxes(subheaderArgs.data, 'td'))
else
table.insert(empty_row_categories, subheaderArgs.data or '')
end
end
local function renderSubheaders()
if args.subheader then
args.subheader1 = args.subheader
end
if args.subheaderrowclass then
args.subheaderrowclass1 = args.subheaderrowclass
end
local subheadernums = getArgNums('subheader')
for k, num in ipairs(subheadernums) do
addSubheaderRow({
data = args['subheader' .. tostring(num)],
-- @deprecated next; target .infobox-<name> .infobox-subheader
datastyle = args.subheaderstyle,
rowcellstyle = args['subheaderstyle' .. tostring(num)],
class = args.subheaderclass,
rowclass = args['subheaderrowclass' .. tostring(num)]
})
end
end
local function addImageRow(imageArgs)
if imageArgs.data and
imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ imageArgs.rowclass, imageArgs.class })
local row = root:tag('tr')
row:addClass(imageArgs.rowclass)
local dataCell = row:tag('td')
dataCell
:attr('colspan', '2')
:addClass('infobox-image')
:addClass(imageArgs.class)
:cssText(imageArgs.datastyle)
:wikitext(fixChildBoxes(imageArgs.data, 'td'))
else
table.insert(empty_row_categories, imageArgs.data or '')
end
end
local function renderImages()
if args.image then
args.image1 = args.image
end
if args.caption then
args.caption1 = args.caption
end
local imagenums = getArgNums('image')
for k, num in ipairs(imagenums) do
local caption = args['caption' .. tostring(num)]
local data = mw.html.create():wikitext(args['image' .. tostring(num)])
if caption then
data
:tag('div')
:addClass('infobox-caption')
-- @deprecated next; target .infobox-<name> .infobox-caption
:cssText(args.captionstyle)
:wikitext(caption)
end
addImageRow({
data = tostring(data),
-- @deprecated next; target .infobox-<name> .infobox-image
datastyle = args.imagestyle,
class = args.imageclass,
rowclass = args['imagerowclass' .. tostring(num)]
})
end
end
-- When autoheaders are turned on, preprocesses the rows
local function preprocessRows()
if not args.autoheaders then return end
local rownums = union(getArgNums('header'), getArgNums('data'))
table.sort(rownums)
local lastheader
for k, num in ipairs(rownums) do
if args['header' .. tostring(num)] then
if lastheader then
args['header' .. tostring(lastheader)] = nil
end
lastheader = num
elseif args['data' .. tostring(num)] and
args['data' .. tostring(num)]:gsub(
category_in_empty_row_pattern, ''
):match('^%S') then
local data = args['data' .. tostring(num)]
if data:gsub(category_in_empty_row_pattern, ''):match('%S') then
lastheader = nil
end
end
end
if lastheader then
args['header' .. tostring(lastheader)] = nil
end
end
-- Gets the union of the header and data argument numbers,
-- and renders them all in order
local function renderRows()
local rownums = union(getArgNums('header'), getArgNums('data'))
table.sort(rownums)
for k, num in ipairs(rownums) do
addRow({
header = args['header' .. tostring(num)],
label = args['label' .. tostring(num)],
data = args['data' .. tostring(num)],
datastyle = args.datastyle,
class = args['class' .. tostring(num)],
rowclass = args['rowclass' .. tostring(num)],
-- @deprecated next; target .infobox-<name> rowclass
rowstyle = args['rowstyle' .. tostring(num)],
rowcellstyle = args['rowcellstyle' .. tostring(num)]
})
end
end
local function renderNavBar()
if not args.name then return end
has_rows = true
root
:tag('tr')
:tag('td')
:attr('colspan', '2')
:addClass('infobox-navbar')
:wikitext(require('Module:Navbar')._navbar{
args.name,
mini = 1,
})
end
local function renderItalicTitle()
local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
root:wikitext(require('Module:Italic title')._main({}))
end
end
-- Categories in otherwise empty rows are collected in empty_row_categories.
-- This function adds them to the module output. It is not affected by
-- args.decat because this module should not prevent module-external categories
-- from rendering.
local function renderEmptyRowCategories()
for _, s in ipairs(empty_row_categories) do
root:wikitext(s)
end
end
-- Render tracking categories. args.decat == turns off tracking categories.
local function renderTrackingCategories()
if args.decat == 'yes' then return end
if args.child == 'yes' then
if args.title then
root:wikitext(
'[[Category:Pages using embedded infobox templates with the title parameter]]'
)
end
elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
root:wikitext('[[Category:Articles using infobox templates with no data rows]]')
end
end
--[=[
Loads the templatestyles for the infobox.
TODO: FINISH loading base templatestyles here rather than in
MediaWiki:Common.css. There are 4-5000 pages with 'raw' infobox tables.
See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :).
When we do this we should clean up the inline CSS below too.
Will have to do some bizarre conversion category like with sidebar.
]=]
local function loadTemplateStyles()
local frame = mw.getCurrentFrame()
local hlist_templatestyles = ''
if lists.hlist_t.found then
hlist_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = lists.hlist_t.styles }
}
end
local plainlist_templatestyles = ''
if lists.plainlist_t.found then
plainlist_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = lists.plainlist_t.styles }
}
end
-- See function description
local base_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Infobox/styles.css' }
}
local templatestyles = ''
if args['templatestyles'] then
templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['templatestyles'] }
}
end
local child_templatestyles = ''
if args['child templatestyles'] then
child_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['child templatestyles'] }
}
end
local grandchild_templatestyles = ''
if args['grandchild templatestyles'] then
grandchild_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
}
end
return table.concat({
-- hlist -> plainlist -> base is best-effort to preserve old Common.css ordering.
-- this ordering is not a guarantee because the rows of interest invoking
-- each class may not be on a specific page
hlist_templatestyles,
plainlist_templatestyles,
base_templatestyles,
templatestyles,
child_templatestyles,
grandchild_templatestyles
})
end
-- common functions between the child and non child cases
local function structure_infobox_common()
renderSubheaders()
renderImages()
preprocessRows()
renderRows()
renderBelowRow()
renderNavBar()
renderItalicTitle()
renderEmptyRowCategories()
renderTrackingCategories()
cleanInfobox()
end
-- Specify the overall layout of the infobox, with special settings if the
-- infobox is used as a 'child' inside another infobox.
local function _infobox()
if args.child ~= 'yes' then
root = mw.html.create('table')
root
:addClass(args.subbox == 'yes' and 'infobox-subbox' or 'infobox')
:addClass(args.bodyclass)
-- @deprecated next; target .infobox-<name>
:cssText(args.bodystyle)
has_list_class({ args.bodyclass })
renderTitle()
renderAboveRow()
else
root = mw.html.create()
root
:wikitext(args.title)
end
structure_infobox_common()
return loadTemplateStyles() .. root
end
-- If the argument exists and isn't blank, add it to the argument table.
-- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
local function preprocessSingleArg(argName)
if origArgs[argName] and origArgs[argName] ~= '' then
args[argName] = origArgs[argName]
end
end
-- Assign the parameters with the given prefixes to the args table, in order, in
-- batches of the step size specified. This is to prevent references etc. from
-- appearing in the wrong order. The prefixTable should be an array containing
-- tables, each of which has two possible fields, a "prefix" string and a
-- "depend" table. The function always parses parameters containing the "prefix"
-- string, but only parses parameters in the "depend" table if the prefix
-- parameter is present and non-blank.
local function preprocessArgs(prefixTable, step)
if type(prefixTable) ~= 'table' then
error("Non-table value detected for the prefix table", 2)
end
if type(step) ~= 'number' then
error("Invalid step value detected", 2)
end
-- Get arguments without a number suffix, and check for bad input.
for i,v in ipairs(prefixTable) do
if type(v) ~= 'table' or type(v.prefix) ~= "string" or
(v.depend and type(v.depend) ~= 'table') then
error('Invalid input detected to preprocessArgs prefix table', 2)
end
preprocessSingleArg(v.prefix)
-- Only parse the depend parameter if the prefix parameter is present
-- and not blank.
if args[v.prefix] and v.depend then
for j, dependValue in ipairs(v.depend) do
if type(dependValue) ~= 'string' then
error('Invalid "depend" parameter value detected in preprocessArgs')
end
preprocessSingleArg(dependValue)
end
end
end
-- Get arguments with number suffixes.
local a = 1 -- Counter variable.
local moreArgumentsExist = true
while moreArgumentsExist == true do
moreArgumentsExist = false
for i = a, a + step - 1 do
for j,v in ipairs(prefixTable) do
local prefixArgName = v.prefix .. tostring(i)
if origArgs[prefixArgName] then
-- Do another loop if any arguments are found, even blank ones.
moreArgumentsExist = true
preprocessSingleArg(prefixArgName)
end
-- Process the depend table if the prefix argument is present
-- and not blank, or we are processing "prefix1" and "prefix" is
-- present and not blank, and if the depend table is present.
if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then
for j,dependValue in ipairs(v.depend) do
local dependArgName = dependValue .. tostring(i)
preprocessSingleArg(dependArgName)
end
end
end
end
a = a + step
end
end
-- Parse the data parameters in the same order that the old {{infobox}} did, so
-- that references etc. will display in the expected places. Parameters that
-- depend on another parameter are only processed if that parameter is present,
-- to avoid phantom references appearing in article reference lists.
local function parseDataParameters()
preprocessSingleArg('autoheaders')
preprocessSingleArg('child')
preprocessSingleArg('bodyclass')
preprocessSingleArg('subbox')
preprocessSingleArg('bodystyle')
preprocessSingleArg('title')
preprocessSingleArg('titleclass')
preprocessSingleArg('titlestyle')
preprocessSingleArg('above')
preprocessSingleArg('aboveclass')
preprocessSingleArg('abovestyle')
preprocessArgs({
{prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}
}, 10)
preprocessSingleArg('subheaderstyle')
preprocessSingleArg('subheaderclass')
preprocessArgs({
{prefix = 'image', depend = {'caption', 'imagerowclass'}}
}, 10)
preprocessSingleArg('captionstyle')
preprocessSingleArg('imagestyle')
preprocessSingleArg('imageclass')
preprocessArgs({
{prefix = 'header'},
{prefix = 'data', depend = {'label'}},
{prefix = 'rowclass'},
{prefix = 'rowstyle'},
{prefix = 'rowcellstyle'},
{prefix = 'class'}
}, 50)
preprocessSingleArg('headerclass')
preprocessSingleArg('headerstyle')
preprocessSingleArg('labelstyle')
preprocessSingleArg('datastyle')
preprocessSingleArg('below')
preprocessSingleArg('belowclass')
preprocessSingleArg('belowstyle')
preprocessSingleArg('name')
-- different behaviour for italics if blank or absent
args['italic title'] = origArgs['italic title']
preprocessSingleArg('decat')
preprocessSingleArg('templatestyles')
preprocessSingleArg('child templatestyles')
preprocessSingleArg('grandchild templatestyles')
end
-- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
function p.infobox(frame)
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame
end
parseDataParameters()
return _infobox()
end
-- For calling via #invoke within a template
function p.infoboxTemplate(frame)
origArgs = {}
for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end
parseDataParameters()
return _infobox()
end
return p
0ddb7e5c8426d67cd589b710efb9912ddfb67fea
Module:List
828
20
43
2022-12-29T17:57:56Z
Template>Izno
0
add templatestyles for hlist
Scribunto
text/plain
local libUtil = require('libraryUtil')
local checkType = libUtil.checkType
local mTableTools = require('Module:TableTools')
local p = {}
local listTypes = {
['bulleted'] = true,
['unbulleted'] = true,
['horizontal'] = true,
['ordered'] = true,
['horizontal_ordered'] = true
}
function p.makeListData(listType, args)
-- Constructs a data table to be passed to p.renderList.
local data = {}
-- Classes and TemplateStyles
data.classes = {}
data.templatestyles = ''
if listType == 'horizontal' or listType == 'horizontal_ordered' then
table.insert(data.classes, 'hlist')
data.templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Hlist/styles.css' }
}
elseif listType == 'unbulleted' then
table.insert(data.classes, 'plainlist')
data.templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Plainlist/styles.css' }
}
end
table.insert(data.classes, args.class)
-- Main div style
data.style = args.style
-- Indent for horizontal lists
if listType == 'horizontal' or listType == 'horizontal_ordered' then
local indent = tonumber(args.indent)
indent = indent and indent * 1.6 or 0
if indent > 0 then
data.marginLeft = indent .. 'em'
end
end
-- List style types for ordered lists
-- This could be "1, 2, 3", "a, b, c", or a number of others. The list style
-- type is either set by the "type" attribute or the "list-style-type" CSS
-- property.
if listType == 'ordered' or listType == 'horizontal_ordered' then
data.listStyleType = args.list_style_type or args['list-style-type']
data.type = args['type']
-- Detect invalid type attributes and attempt to convert them to
-- list-style-type CSS properties.
if data.type
and not data.listStyleType
and not tostring(data.type):find('^%s*[1AaIi]%s*$')
then
data.listStyleType = data.type
data.type = nil
end
end
-- List tag type
if listType == 'ordered' or listType == 'horizontal_ordered' then
data.listTag = 'ol'
else
data.listTag = 'ul'
end
-- Start number for ordered lists
data.start = args.start
if listType == 'horizontal_ordered' then
-- Apply fix to get start numbers working with horizontal ordered lists.
local startNum = tonumber(data.start)
if startNum then
data.counterReset = 'listitem ' .. tostring(startNum - 1)
end
end
-- List style
-- ul_style and ol_style are included for backwards compatibility. No
-- distinction is made for ordered or unordered lists.
data.listStyle = args.list_style
-- List items
-- li_style is included for backwards compatibility. item_style was included
-- to be easier to understand for non-coders.
data.itemStyle = args.item_style or args.li_style
data.items = {}
for _, num in ipairs(mTableTools.numKeys(args)) do
local item = {}
item.content = args[num]
item.style = args['item' .. tostring(num) .. '_style']
or args['item_style' .. tostring(num)]
item.value = args['item' .. tostring(num) .. '_value']
or args['item_value' .. tostring(num)]
table.insert(data.items, item)
end
return data
end
function p.renderList(data)
-- Renders the list HTML.
-- Return the blank string if there are no list items.
if type(data.items) ~= 'table' or #data.items < 1 then
return ''
end
-- Render the main div tag.
local root = mw.html.create('div')
for _, class in ipairs(data.classes or {}) do
root:addClass(class)
end
root:css{['margin-left'] = data.marginLeft}
if data.style then
root:cssText(data.style)
end
-- Render the list tag.
local list = root:tag(data.listTag or 'ul')
list
:attr{start = data.start, type = data.type}
:css{
['counter-reset'] = data.counterReset,
['list-style-type'] = data.listStyleType
}
if data.listStyle then
list:cssText(data.listStyle)
end
-- Render the list items
for _, t in ipairs(data.items or {}) do
local item = list:tag('li')
if data.itemStyle then
item:cssText(data.itemStyle)
end
if t.style then
item:cssText(t.style)
end
item
:attr{value = t.value}
:wikitext(t.content)
end
return data.templatestyles .. tostring(root)
end
function p.renderTrackingCategories(args)
local isDeprecated = false -- Tracks deprecated parameters.
for k, v in pairs(args) do
k = tostring(k)
if k:find('^item_style%d+$') or k:find('^item_value%d+$') then
isDeprecated = true
break
end
end
local ret = ''
if isDeprecated then
ret = ret .. '[[Category:List templates with deprecated parameters]]'
end
return ret
end
function p.makeList(listType, args)
if not listType or not listTypes[listType] then
error(string.format(
"bad argument #1 to 'makeList' ('%s' is not a valid list type)",
tostring(listType)
), 2)
end
checkType('makeList', 2, args, 'table')
local data = p.makeListData(listType, args)
local list = p.renderList(data)
local trackingCategories = p.renderTrackingCategories(args)
return list .. trackingCategories
end
for listType in pairs(listTypes) do
p[listType] = function (frame)
local mArguments = require('Module:Arguments')
local origArgs = mArguments.getArgs(frame, {
valueFunc = function (key, value)
if not value or not mw.ustring.find(value, '%S') then return nil end
if mw.ustring.find(value, '^%s*[%*#;:]') then
return value
else
return value:match('^%s*(.-)%s*$')
end
return nil
end
})
-- Copy all the arguments to a new table, for faster indexing.
local args = {}
for k, v in pairs(origArgs) do
args[k] = v
end
return p.makeList(listType, args)
end
end
return p
7a4f36a6e9cd56370bdd8207d23694124821dc1a
Module:Navbar/configuration
828
38
79
2022-12-29T18:18:21Z
Template>Izno
0
add hlist/styles.css
Scribunto
text/plain
return {
['templatestyles'] = 'Module:Navbar/styles.css',
['hlist_templatestyles'] = 'Hlist/styles.css',
['box_text'] = 'This box: ', -- default text box when not plain or mini
['title_namespace'] = 'Template', -- namespace to default to for title
['invalid_title'] = 'Invalid title ',
['classes'] = { -- set a line to nil if you don't want it
['navbar'] = 'navbar',
['plainlinks'] = 'plainlinks', -- plainlinks
['horizontal_list'] = 'hlist', -- horizontal list class
['mini'] = 'navbar-mini', -- class indicating small links in the navbar
['this_box'] = 'navbar-boxtext',
['brackets'] = 'navbar-brackets',
-- 'collapsible' is the key for a class to indicate the navbar is
-- setting up the collapsible element in addition to the normal
-- navbar.
['collapsible'] = 'navbar-collapse',
['collapsible_title_mini'] = 'navbar-ct-mini',
['collapsible_title_full'] = 'navbar-ct-full'
}
}
b007c336b17ec4bcd4d5a9dca9f8cba301662b55
Module:Navbar
828
37
77
2022-12-29T18:20:02Z
Template>Izno
0
add templatestyles for hlist
Scribunto
text/plain
local p = {}
local cfg = mw.loadData('Module:Navbar/configuration')
local function get_title_arg(is_collapsible, template)
local title_arg = 1
if is_collapsible then title_arg = 2 end
if template then title_arg = 'template' end
return title_arg
end
local function choose_links(template, args)
-- The show table indicates the default displayed items.
-- view, talk, edit, hist, move, watch
-- TODO: Move to configuration.
local show = {true, true, true, false, false, false}
if template then
show[2] = false
show[3] = false
local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6,
talk = 2, edit = 3, hist = 4, move = 5, watch = 6}
-- TODO: Consider removing TableTools dependency.
for _, v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do
local num = index[v]
if num then show[num] = true end
end
end
local remove_edit_link = args.noedit
if remove_edit_link then show[3] = false end
return show
end
local function add_link(link_description, ul, is_mini, font_style)
local l
if link_description.url then
l = {'[', '', ']'}
else
l = {'[[', '|', ']]'}
end
ul:tag('li')
:addClass('nv-' .. link_description.full)
:wikitext(l[1] .. link_description.link .. l[2])
:tag(is_mini and 'abbr' or 'span')
:attr('title', link_description.html_title)
:cssText(font_style)
:wikitext(is_mini and link_description.mini or link_description.full)
:done()
:wikitext(l[3])
:done()
end
local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
if not title then
error(cfg.invalid_title .. title_text)
end
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
-- TODO: Get link_descriptions and show into the configuration module.
-- link_descriptions should be easier...
local link_descriptions = {
{ ['mini'] = 'v', ['full'] = 'view', ['html_title'] = 'View this template',
['link'] = title.fullText, ['url'] = false },
{ ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template',
['link'] = talkpage, ['url'] = false },
{ ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template',
['link'] = title:fullUrl('action=edit'), ['url'] = true },
{ ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template',
['link'] = title:fullUrl('action=history'), ['url'] = true },
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
['link'] = title:fullUrl('action=watch'), ['url'] = true }
}
local ul = mw.html.create('ul')
if has_brackets then
ul:addClass(cfg.classes.brackets)
:cssText(font_style)
end
for i, _ in ipairs(displayed_links) do
if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
end
return ul:done()
end
function p._navbar(args)
-- TODO: We probably don't need both fontstyle and fontcolor...
local font_style = args.fontstyle
local font_color = args.fontcolor
local is_collapsible = args.collapsible
local is_mini = args.mini
local is_plain = args.plain
local collapsible_class = nil
if is_collapsible then
collapsible_class = cfg.classes.collapsible
if not is_plain then is_mini = 1 end
if font_color then
font_style = (font_style or '') .. '; color: ' .. font_color .. ';'
end
end
local navbar_style = args.style
local div = mw.html.create():tag('div')
div
:addClass(cfg.classes.navbar)
:addClass(cfg.classes.plainlinks)
:addClass(cfg.classes.horizontal_list)
:addClass(collapsible_class) -- we made the determination earlier
:cssText(navbar_style)
if is_mini then div:addClass(cfg.classes.mini) end
local box_text = (args.text or cfg.box_text) .. ' '
-- the concatenated space guarantees the box text is separated
if not (is_mini or is_plain) then
div
:tag('span')
:addClass(cfg.classes.box_text)
:cssText(font_style)
:wikitext(box_text)
end
local template = args.template
local displayed_links = choose_links(template, args)
local has_brackets = args.brackets
local title_arg = get_title_arg(is_collapsible, template)
local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
div:node(list)
if is_collapsible then
local title_text_class
if is_mini then
title_text_class = cfg.classes.collapsible_title_mini
else
title_text_class = cfg.classes.collapsible_title_full
end
div:done()
:tag('div')
:addClass(title_text_class)
:cssText(font_style)
:wikitext(args[1])
end
local frame = mw.getCurrentFrame()
-- hlist -> navbar is best-effort to preserve old Common.css ordering.
return frame:extensionTag{
name = 'templatestyles', args = { src = cfg.hlist_templatestyles }
} .. frame:extensionTag{
name = 'templatestyles', args = { src = cfg.templatestyles }
} .. tostring(div:done())
end
function p.navbar(frame)
return p._navbar(require('Module:Arguments').getArgs(frame))
end
return p
79f907e59eaa8bbf8dd50bb751933ebeaaa7eb17
Template:Distinguish
10
27
57
2023-02-04T21:16:13Z
Template>Hog Farm
0
[[Wikipedia:Templates for discussion/Log/2023 February 4#Template:Distinguish]] closed as keep ([[WP:XFDC#4.0.13|XFDcloser]])
wikitext
text/x-wiki
{{#invoke:Distinguish|distinguish}}<noinclude><!-- splitting these lines causes {{Documentation}} template to terminate green shading when Distinguish is used in /doc pages. -->
{{Documentation}}
<!-- Add categories to the /doc subpage and interwikis to Wikidata, not here! -->
</noinclude>
f949a4cbfd6eb0ab77b832e69059a40a964b1fd8
Template:Template
10
110
223
2023-02-08T16:11:22Z
w>Xaosflux
0
Reverted edits by [[Special:Contribs/Xaosflux|Xaosflux]] ([[User talk:Xaosflux|talk]]) to last version by Redrose64
wikitext
text/x-wiki
#REDIRECT [[Template:Template link]]
fb9a6b420e13178e581af6e7d64274cd30a79017
Module:Lua banner
828
63
129
2023-02-16T14:39:53Z
Template>Uzume
0
[[Module:Citation]] has been blanked since [[Wikipedia:Templates for discussion/Log/2018 May 13#Module:Citation]]; remove special handling
Scribunto
text/plain
-- This module implements the {{lua}} template.
local yesno = require('Module:Yesno')
local mList = require('Module:List')
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')
local p = {}
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('^%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
function p._main(args)
local modules = mTableTools.compressSparseArray(args)
local box = p.renderBox(modules)
local trackingCategories = p.renderTrackingCategories(args, modules)
return box .. trackingCategories
end
function p.renderBox(modules)
local boxArgs = {}
if #modules < 1 then
boxArgs.text = '<strong class="error">Error: no modules specified</strong>'
else
local moduleLinks = {}
for i, module in ipairs(modules) do
moduleLinks[i] = string.format('[[:%s]]', module)
local maybeSandbox = mw.title.new(module .. '/sandbox')
if maybeSandbox.exists then
moduleLinks[i] = moduleLinks[i] .. string.format(' ([[:%s|sandbox]])', maybeSandbox.fullText)
end
end
local moduleList = mList.makeList('bulleted', moduleLinks)
local title = mw.title.getCurrentTitle()
if title.subpageText == "doc" then
title = title.basePageTitle
end
if title.contentModel == "Scribunto" then
boxArgs.text = 'This module depends on the following other modules:' .. moduleList
else
boxArgs.text = 'This template uses [[Wikipedia:Lua|Lua]]:\n' .. moduleList
end
end
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.image = '[[File:Lua-Logo.svg|30px|alt=|link=]]'
return mMessageBox.main('mbox', boxArgs)
end
function p.renderTrackingCategories(args, modules, titleObj)
if yesno(args.nocat) then
return ''
end
local cats = {}
-- Error category
if #modules < 1 then
cats[#cats + 1] = 'Lua templates with errors'
end
-- Lua templates category
titleObj = titleObj or mw.title.getCurrentTitle()
local subpageBlacklist = {
doc = true,
sandbox = true,
sandbox2 = true,
testcases = true
}
if not subpageBlacklist[titleObj.subpageText] then
local protCatName
if titleObj.namespace == 10 then
local category = args.category
if not category then
local categories = {
['Module:String'] = 'Templates based on the String Lua module',
['Module:Math'] = 'Templates based on the Math Lua module',
['Module:BaseConvert'] = 'Templates based on the BaseConvert Lua module',
['Module:Citation/CS1'] = 'Templates based on the Citation/CS1 Lua module'
}
category = modules[1] and categories[modules[1]]
category = category or 'Lua-based templates'
end
cats[#cats + 1] = category
protCatName = "Templates using under-protected Lua modules"
elseif titleObj.namespace == 828 then
protCatName = "Modules depending on under-protected modules"
end
if not args.noprotcat and protCatName then
local protLevels = {
autoconfirmed = 1,
extendedconfirmed = 2,
templateeditor = 3,
sysop = 4
}
local currentProt
if titleObj.id ~= 0 then
-- id is 0 (page does not exist) if am previewing before creating a template.
currentProt = titleObj.protectionLevels["edit"][1]
end
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
for i, module in ipairs(modules) do
if module ~= "WP:libraryUtil" then
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
if moduleProt < currentProt then
cats[#cats + 1] = protCatName
break
end
end
end
end
end
for i, cat in ipairs(cats) do
cats[i] = string.format('[[Category:%s]]', cat)
end
return table.concat(cats)
end
return p
03ec1b34a40121efc562c0c64a67ebbf57d56dff
Template:Infobox ship begin/doc
10
120
243
2023-02-22T19:14:56Z
w>Gonnym
0
tag with {{Auto italic title}}
wikitext
text/x-wiki
{{Documentation subpage}}
{{High-use}}
{{Auto italic title|1=display title|2=template|3=none|short=y}}
{{Infobox ship begin/shared doc}}
===TemplateData===
{{TemplateData header}}
<templatedata>
{
"description": "Start template for Infobox ship (see template documentation), includes optional caption for the infobox",
"params": {
"Infobox caption": {
"label": "infobox caption",
"type": "string",
"required": false,
"description": "Caption for the infobox. Set to yes to use formatted article title; set to nodab to use formatted article title without parenthetical disambiguator; all other values become infobox caption."
},
"showerrs": {},
"sclass": {},
"display title": {}
},
"format": "block"
}
</templatedata>
=== See also ===
* {{tlx|WikiProject Ships|needs-infobox{{=}}y}}
<!--IMPORTANT:
{{Infobox ship begin/shared doc}} adds some categories. You should probably edit that page.
-->
c5ed959526f629f3bd96d5d912374751dcff1ff4
Module:WPSHIPS utilities
828
108
219
2023-03-04T20:11:46Z
w>Trappist the monk
0
Scribunto
text/plain
require('strict')
local get_args = require ('Module:Arguments').getArgs;
local styles = require ('Module:WPMILHIST Infobox style'); -- infobox css
local data = mw.loadData ('Module:WPSHIPS utilities/data');
local namespace = mw.title.getCurrentTitle().namespace; -- used for categorization
--[[--------------------------< E R R O R _ M A P _ T >--------------------------------------------------------
]]
local error_map_t = { -- [1] is error message; [2] is error category
synonymous = {'has synonymous parameter', 'Category:Pages using infobox ship with synonymous parameters'};
missing = {'missing required parameter: %s', 'Category:WPSHIPS: sclass and sclass2 errors'},
format = {'invalid format code: %s. Should be 0–5, or blank', 'Category:WPSHIPS: sclass and sclass2 errors'},
}
--[[--------------------------< E R R O R _ M S G _ M A K E >--------------------------------------------------
assembles an error message from message text and category in <error_map_t>. creates a help link to the category
page; categorizes only main and template namespaces.
<no_cat> disables categorization for those templates that support it; to disable categorization set <no_cat> true
]]
local function error_msg_make (msg_idx, template, detail, no_cat)
local out = {};
local category;
table.insert (out, '<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">Error: '); --TODO: simplify?
if template then
table.insert (out, table.concat ({'{{', template, '}} '})); -- TODO: get template names for synonymous parameter errors
end
table.insert (out, string.format (error_map_t[msg_idx][1], detail)); -- build error message from base + <detail>
table.insert (out, table.concat ({' ([[:', error_map_t[msg_idx][2], '|help]])'})); -- help text on category pages; TODO: help text on template pages also?
table.insert (out, '</span>');
if (0 == namespace or 10 == namespace) and not no_cat then -- categorize in article space (and template space to take care of broken usages)
table.insert (out, table.concat ({'[[', error_map_t[msg_idx][2], ']]'}));
end
return table.concat (out); -- make a big string and done
end
--[[--------------------------< I S _ S E T >------------------------------------------------------------------
Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
]]
local function is_set( var )
return not (var == nil or var == '');
end
--[[--------------------------< S I Z E O F _ S H I P _ T Y P E >----------------------------------------------
Returns the size in words of ship type. Inputs are the fragment table, the number of elements in the fragment table,
and the number of words that make up nationality.
The number of fragments (words) in a ship name dictate the possible sizes of ship type. If nationality takes one fragment,
and ship type takes four fragments, then the minimum number of fragments in a composite ship name is:
5 = 1 (nationality) + 3 (ship type) + 1 (ship name) (same as 4 fragments (words) after nationality)
This function starts at the longest possible series of fragments that might be ship type. This order is important becuase
some ship types might begin with similar fragments: 'ship' and 'ship of the line'. Starting with the least possible
series of fragments (1) would find 'ship' and make 'of the line' part of the italicized name.
Returns 0 if there is no recognizable ship type.
]]
local function sizeof_ship_type (frag, frag_len, nat_len)
local ship_type;
if 5 <= (frag_len - nat_len) then -- must have at least five fragments after nationality for four-word ship type
ship_type = table.concat (frag, ' ', nat_len+1, nat_len+4); -- four-word ship type
if data.ship_type_t[ship_type] then
return 4;
end
end
if 4 <= (frag_len - nat_len) then -- must have at least four fragments after nationality for three-word ship type
ship_type = table.concat (frag, ' ', nat_len+1, nat_len+3); -- three-word ship type
if data.ship_type_t[ship_type] then
return 3;
end
end
if 3 <= (frag_len - nat_len) then -- must have at least three fragments after nationality for two-word ship type
ship_type = table.concat (frag, ' ', nat_len+1, nat_len+2); -- two-word ship type
if data.ship_type_t[ship_type] then
return 2;
end
end
if 2 <= (frag_len - nat_len) then -- must have at least two fragments after nationality for one-word ship type
if data.ship_type_t[frag[nat_len+1]] then -- one-word ship type
return 1;
end
end
return 0; -- no recognizable ship type
end
--[[--------------------------< S I Z E O F _ N A T I O N A L I T Y >------------------------------------------
This function the size (in words) of the nationality from the fragments table. Nationality may be one or two
words that occupy the first one or two positions in the table.
Returns the number of words that identify the nationality:
1 for French or German, etc.
2 for United States;
0 when table doesn't have a recognizable nationality
]]
local function sizeof_nationality (frag, frag_len)
local nat = '';
if not data.nationality_t [frag[1]] then -- if not a one-word nationality
if 2 <= frag_len - 2 then -- must have at least two fragments after nationality for minimal ship type and name
nat = table.concat (frag, ' ', 1, 2);
if data.nationality_t [nat] then -- is it a two-word nationality?
return 2; -- yes
else
return 0; -- no
end
end
return 0; -- not one-word and not enough fragments for two-word
end
return 1; -- one-word nationality
end
--[[-------------------------< D O _ S H I P _ N A M E _ F O R M A T >-----------------------------------------
This function applies correct styling to ship and ship-class names. These names are, for example, ship-article titles
used by templates {{navsource}}, {{Infobox ship begin}}, where the article title is to be rendered with proper
styling.
This function requires one argument:
|name= (required): a name is required; if missing or empty, this function returns an error message (may or may not be visible depending on where it is used)
used in {{infobox ship begin}} to provide a value for {{DISPLAYTITLE:}} and to provide a value for |infobox caption=
{{#invoke:WPSHIPS_utilities|ship_name_format|name={{PAGENAME}}}}
Optional arguments to support {{infobox ship begin}}:
|dab=none – displays ship name without parenthetical disambiguator; use when |infobox caption=nodab
|sclass=2 – for ship classes only; displays class name without italics (parameter name is loosely similar to {{slcass2}} which does the same thing); use when |infobox caption=class
|adj=off – for ship classes only; displays class name as a noun (no hyphen, no ship type); use when |infobox caption=class
Arguments are passed in a table.
to call this function locally:
do_ship_name_format ({['name=name'], ['dab']=dab, ['sclass']=sclass, ['adj']=adj, ['showerrs']=showerrs}) or
args = {['name=name'], ['dab']=dab, ['sclass']=sclass, ['adj']=adj, ['showerrs']=showerrs};
do_ship_name_format (args)
The function returns the formatted name or, if unable to format the name, the original name and an unformatted error message.
]]
local function do_ship_name_format (args)
local name_sans_dab; -- the ship or class name without a trailing parenthetical dab
local dab; -- the dab stripped from the name
local fragments = {}; -- a table of words that make up name_sans_dab
local ship_type; -- a word or phrase that describes a ship
local type_len; -- the number of words that describe a ship
local nat_len; -- the number of words used to specify a ship's nationality
local name = ''; -- the reassembles and formatted ship name
local error_msg = ''; -- a repository for error messages if any
-- args.name = mw.text.decode (args.name); -- replace html entities in title with their characters; doesn't work for & and & in prefix
args.name = args.name:gsub ("'", "\'"); -- replace html appostrophe with the character
-- args.name = args.name:gsub ("&", "&");
-- args.name = args.name:gsub ("&", "&");
-- args.name = args.name:gsub ("&", "&");
if args.name:match ('.+%-class%s+%a+') then -- if a ship-class
fragments = mw.text.split (args.name, '-class' ); -- split at -class
if '2' == args.sclass then -- for DISPLAYTITLE and infobox caption when class not named for a member of the class
if 'off' == args.adj then
return fragments[1] .. ' class'; -- for infobox caption do noun form <name> class (no hyphen, no ship type)
end
return args.name; -- nothing to do so return original unformatted name
end
if 'off' == args.adj then
return "''" .. fragments[1] .. "'' class"; -- for infobox caption do noun form <name> class (no hyphen, no ship type)
end
return "''" .. fragments[1] .. "''-class" .. fragments[2]; -- and return formatted adjectival name
end
-- not a ship class so try to format a ship name
name_sans_dab, dab = args.name:match('^(.+)%s+(%b())%s*$'); -- split name into name_sans_dab and dab
if is_set (dab) then
dab = ' ' .. dab; -- insert a space for later reassembly
else
name_sans_dab = args.name; -- because without a dab, the string.match returns nil
dab = ''; -- empty string for concatenation
end
fragments = mw.text.split (name_sans_dab, '%s' ); -- split into a table of separate words
nat_len = sizeof_nationality (fragments, #fragments); -- get the number of words in the ship's nationality
if 0 < nat_len then -- if not zero we have a valid nationality
type_len = sizeof_ship_type (fragments, #fragments, nat_len); -- get the number of words in the ship type
if 0 < type_len then -- if not zero, ship type is valid; nationality and type not italics, the rest is name
name = "''" .. table.concat (fragments, ' ', nat_len + type_len + 1) .. "''"; -- format name
if 'none' == args.dab then -- for |infobox caption=nodab
return name; -- return the formatted name without the nationality or ship type or dab
end
name = table.concat (fragments, ' ', 1, nat_len + type_len) .. " " .. name; -- assemble everything but dab
else
error_msg = ' unrecognized ship type;'; -- valid nationality, invalid ship type
end
elseif data.ship_prefix_t[fragments[1]] then -- if the first fragment is a ship prefix
name = table.remove (fragments, 1); -- fetch it from the table
name = name .. " ''" .. table.concat (fragments, ' ') .. "''"; -- assemble formatted name
else
error_msg = ' no nationality or prefix;'; -- invalid nationality and first word in ship name not a valid prefix
end
if is_set (name) then -- name will be set if we were able to format it
if 'none' == args.dab then -- for |infobox caption=nodab
return name; -- return the formatted name without the dab
end
return name .. dab; -- return the formatted name with the dab
end
if is_set (dab) then
if dab:match ('%(%u+[%- ]?%d+%)') or -- one or more uppercase letters, optional space or hyphen, one or more digits
dab:match ('%(%d+[%- ]?%u+%)') or -- one or more digits, optional space or hyphen, one or more uppercase letters
dab:match ('%(%u[%u%-]*%-%d+%)') or -- one or more uppercase letters with hyphens, a hyphen, one or more digits (e.g., T-AO-157)
dab:match ('%([12]%d%d%d%)') then -- four digits representing year in the range 1000–2999
name = "''" .. table.concat (fragments, ' ') .. "''"; -- format the name
if 'none' == args.dab then -- for |infobox caption=nodab
return name; -- return the formatted name without the dab
end
return name .. dab; -- return the formatted name with the dab
end
-- last chance, is there a ship type in the dab?
for key, _ in pairs (data.ship_type_t) do -- spin through the ship type list and see if there is a ship type (key) in the dab
if dab:find ('%f[%a]' .. key .. '%f[^%a]') then -- avoid matches that are not whole word
name = "''" .. table.concat (fragments, ' ') .. "''"; -- format the name
if 'none' == args.dab then -- for |infobox caption=nodab
return name; -- return the formatted name without the dab
end
return name .. dab; -- return the formatted name with the dab
end
end
error_msg = error_msg .. ' no ship type in dab;';
if 'none' == args.dab then -- for |infobox caption=nodab
return table.concat (fragments, ' '), error_msg; -- return the unformatted name without the dab, and an error message
end
end
return args.name, error_msg; -- return original un-formatted name with unformatted error message if any
end
--[[-------------------------< S H I P _ N A M E _ F O R M A T >-----------------------------------------------
This function is the external interface to do_ship_name_format().
The function requires one parameter:
|name= (required): a name is required; if missing or empty, this function returns an error message (may or may not be visible depending on where it is used)
used in {{infobox ship begin}} to provide a value for {{DISPLAYTITLE:}} and to provide a value for |infobox caption=
{{#invoke:WPSHIPS_utilities|ship_name_format|name={{PAGENAME}}}}
Optional parameters to support {{infobox ship begin}}:
|dab=none – displays ship name without parenthetical disambiguator; use when |infobox caption=nodab
|sclass=2 – for ship classes only; displays class name without italics (parameter name is loosely similar to {{slcass2}} which does the same thing); use when |infobox caption=class
|adj=off – for ship classes only; displays class name as a noun (no hyphen, no ship type); use when |infobox caption=class
Other optional parameters:
|showerrs=yes – marginally useful; can display error messages if the module invocation is not buried in a template
Values from the above parameters are placed in a table and that table passed as an argument in the call to do_ship_name_format().
do_ship_name_format() returns two strings: a name and an error message. If do_ship_name_format() could format the name, it returns the formatted name and
an empty string for the error message. If it could not format the name, do_ship_name_format() returns the original name and an error message.
Formatting of the error message, in response to |showerrs=yes is the responsibility of the calling function.
]]
local function ship_name_format(frame)
local name = ''; -- destination of the formatted ship name
local error_msg = ''; -- destination of any error message
if not is_set (frame.args.name) then -- if a ship name not provided
if 'yes' == frame.args.showerrs then -- and we're supposed to show errors
error_msg = '<span style="font-size:100%; font-weight:normal" class="error">Empty name</span>'; -- return an empty string error message if there is no name
end
else
name, error_msg = do_ship_name_format (frame.args); -- get formatted name and error message
if is_set (error_msg) and 'yes' == frame.args.showerrs then -- if appropriate, show error message
error_msg = '<span style="font-size:100%; font-weight:normal" class="error">' .. error_msg .. '</span>';
else
error_msg = ''; -- for concatenation
end
end
return name .. error_msg; -- return name and error message
end
--[[--------------------------< H N S A >----------------------------------------------------------------------
Similar to {{navsource}}, this code supports {{hnsa}} by attempting to construct a link to a ship article at the
the Historic Nava Ships Association website.
The template has the form:
{{hnsa|<page>|<name>}}
where:
<page> is the name of the page at http://hnsa.org/hnsa-ships/<page>
<name> (optional) is the name of the ship; if left blank, the template uses the current page title; if a ship name, it is formatted
from which this code produces:
[http://hnsa.org/hnsa-ships/<page> <name>] at Historic Naval Ships Association
]]
local function hnsa (frame)
local pframe = frame:getParent() -- get arguments from calling template frame
local ship_name = '';
local error_msg = '';
local article_title = mw.title.getCurrentTitle().text; -- fetch the article title
if not is_set (pframe.args[1]) then
return '<span style="font-size:100%; font-weight:normal" class="error">missing hsna page</span>';
end
local fmt_params = {['name']='', ['showerrs']=nil};
if is_set (pframe.args.showerrs) then -- if showerrs set in template, override showerrs in #invoke:
fmt_params.showerrs = pframe.args.showerrs; -- template value
else
fmt_params.showerrs = frame.args.showerrs; -- invoke value
end
if is_set (pframe.args[2]) then
fmt_params.name = pframe.args[2];
else
fmt_params.name = article_title; -- use article title
end
ship_name, error_msg = do_ship_name_format (fmt_params);
if is_set (error_msg) and is_set (pframe.args[2]) then -- if unable to format the name
local escaped_name = pframe.args[2]:gsub("([%(%)%.%-])", "%%%1"); -- escape some of the Lua magic characters
if pframe.args[2] == article_title or -- is name same as article title?
nil ~= article_title:find ('%f[%a]' .. escaped_name .. '%f[%s]') or -- is name a word or words substring of article title?
nil ~= article_title:find ('%f[%a]' .. escaped_name .. '$') then -- is name a word or words substring that ends article title?
ship_name = "''" .. pframe.args[2] .. "''"; -- non-standard 'name'; perhaps just the name without prefix and dab;
error_msg = ''; -- unset because we think we have a name
end
end
if is_set (error_msg) and 'yes' == fmt_params.showerrs then
error_msg = '<span style="font-size:100%; font-weight:normal" class="error">' .. error_msg .. '</span>';
else
error_msg = ''; -- unset so it doesn't diplay
end
local output = {
'[http://www.hnsa.org/hnsa-ships/',
pframe.args[1],
'/ ',
ship_name,
'] at Historic Naval Ships Association',
error_msg,
}
return table.concat (output);
end
--[[--------------------------< N A V S O U R C E >------------------------------------------------------------
This version of the template {{navsource}} was added as a test vehicle for do_ship_name_format().
]]
local function navsource (frame)
local pframe = frame:getParent() -- get arguments from calling template frame
local ship_name = '';
local error_msg = '';
local article_title = mw.title.getCurrentTitle().text; -- fetch the article title
if not is_set (pframe.args[1]) then
return '<span style="font-size:100%; font-weight:normal" class="error">missing navsource URLcode</span>';
end
local fmt_params = {['name']='', ['showerrs']=nil};
if is_set (pframe.args.showerrs) then -- if showerrs set in template, override showerrs in #invoke:
fmt_params.showerrs = pframe.args.showerrs; -- template value
else
fmt_params.showerrs = frame.args.showerrs; -- invoke value
end
if is_set (pframe.args[2]) then
fmt_params.name = pframe.args[2];
else
fmt_params.name = article_title; -- use article title
end
ship_name, error_msg = do_ship_name_format (fmt_params);
if is_set (error_msg) and is_set (pframe.args[2]) then -- if unable to format the name
local escaped_name = pframe.args[2]:gsub("([%(%)%.%-])", "%%%1"); -- escape some of the Lua magic characters
if pframe.args[2] == article_title or -- is name same as article title?
nil ~= article_title:find ('%f[%a]' .. escaped_name .. '%f[%s]') or -- is name a word or words substring of article title?
nil ~= article_title:find ('%f[%a]' .. escaped_name .. '$') then -- is name a word or words substring that ends article title?
ship_name = "''" .. pframe.args[2] .. "''"; -- non-standard 'name'; perhaps just the name without prefix and dab;
error_msg = ''; -- unset because we think we have a name
end
end
if is_set (error_msg) and 'yes' == fmt_params.showerrs then
error_msg = '<span style="font-size:100%; font-weight:normal" class="error">' .. error_msg .. '</span>';
else
error_msg = ''; -- unset so it doesn't diplay
end
local output = {
'[http://www.navsource.org/archives/',
pframe.args[1],
'.htm Photo gallery] of ',
ship_name,
' at NavSource Naval History',
error_msg,
}
return table.concat (output);
end
--[[--------------------------< _ S H I P >--------------------------------------------------------------------
This is a possible replacement for the template {{ship}}. It has better error detection and handling.
]]
local function _ship (prefix, name, dab, control, unlinked_prefix, unlinked_whole)
local error_msg = '';
local category = '';
if not is_set (control) then
control = ''; -- if not provided, ensure that control is empty string for comparisons
elseif control:find ('%-') then -- shortcut for |link=no when using a format control parameter ...|SSBN-659|-6}} same as ...|SSBN-659|6|link=no}}
unlinked_whole = true; -- set the unlinked flag
control = control:match ('%d'); -- strip out the hyphen
end
-- dispose of error conditions straight away
if not is_set (name) then -- this is the only required parameter
error_msg = ' missing name';
elseif not is_set (dab) and ('1' == control or '3' == control or '5' == control) then -- dab required when control value set to expect it
error_msg = ' missing disambiguator';
elseif not is_set (prefix) and ('5' == control or '6' == control) then -- prefix required when control value set to expect it
error_msg = ' missing prefix';
elseif '4' == control then -- displaying only the prefix
error_msg = 'invalid control parameter: ' .. control;
elseif is_set (control) then
if ('number' ~= type (tonumber (control))) or (1 > tonumber (control) or 6 < tonumber (control)) then -- control must be a number between 1 through 6
error_msg = 'invalid control parameter: ' .. control;
end
elseif not is_set (prefix) and unlinked_prefix then -- prefix required when |up=yes
error_msg = ' missing prefix';
end
if is_set (error_msg) then
if 0 == mw.title.getCurrentTitle().namespace then -- only categorize pages in article space
category = '[[Category:WPSHIPS: template ship parameter errors]]';
end
return '<span style="font-size:100%" class="error">' .. error_msg .. '</span>' .. category; -- return an error message; don't bother with making a link
end
local link_name;
local link = '[[';
if is_set (prefix) then
link = link .. prefix .. ' ' .. name; -- begin assembling the article name portion of the wikilink
else
link = link .. name;
end
if is_set (dab) then
link = link .. ' (' .. dab .. ')'; -- wrap dab in parentheses
end
name = "''" .. name .. "''"; -- name is always italicized so do it now
if '1' == control then
link_name = dab; -- special case when displaying only the dab, don't wrap in parentheses
end
if is_set (dab) then -- for all other cases that display dab
if '5' == control then
dab = " \'\'" .. dab .. "\'\'"; -- for prefix with dab display HMS A1. italicize the dab
else
dab = ' (' .. dab .. ')'; -- except for dab-only, all others display with parentheses
end
end
if not is_set (control) then -- when control not set: prefix, name, and dab
if unlinked_prefix then -- 'unlinked prefix'?
link = prefix .. ' ' .. link; -- yes, modify link so that prefix is not linked in final render
link_name = name .. dab;
elseif is_set (prefix) then
link_name = prefix .. ' ' .. name .. dab;
else
link_name = name .. dab;
end
else -- when control is not 1 or none
if '2' == control then -- name only
link_name = name;
elseif '3' == control then -- name and dab
link_name = name .. dab;
elseif '5' == control then -- prefix and dab
if unlinked_prefix then -- 'unlinked prefix'?
link = prefix .. ' ' .. link; -- yes, modify link so that prefix is not linked in final render
link_name = dab;
else
link_name = prefix .. dab;
end
elseif '6' == control then -- prefix and name
if unlinked_prefix then -- 'unlinked prefix'?
link = prefix .. ' ' .. link; -- yes, modify link so that prefix is not linked in final render
link_name = name;
else
link_name = prefix .. ' ' .. name;
end
end
end
if unlinked_whole then
return link_name;
else
return link .. '|' .. link_name .. ']]';
end
end
--[[--------------------------< S H I P >----------------------------------------------------------------------
This is a possible replacement for the template {{ship}}. It has better error detection and handling.
This function is the externally accessible entry point for template {{ship}}, {{HMS}}, {{USS}}, etc
{{#invoke:WPSHIPS_utilities/sandbox|ship|{{{1|}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}|link={{{link|}}}|up={{{up|}}}}}
]]
local function ship (frame) -- this version not supported from the template yet
local prefix = mw.text.trim (frame.args[1] or ''); -- fetch positional parameters into named variables for readability
local name = mw.text.trim (frame.args[2] or ''); -- stripped of leading and trailing whitespace
local dab = mw.text.trim (frame.args[3] or ''); -- and and set to empty string (is that needed?)
local control = frame.args[4];
local unlinked_prefix = 'yes' == frame.args.up;
local unlinked_whole = 'no' == frame.args.link;
return _ship (prefix, name, dab, control, unlinked_prefix, unlinked_whole);
end
--[[--------------------------< L I S T _ E R R O R >----------------------------------------------------------
Assembles an error message, the original parameter value and, if appropriate a category. The error message precedes
the existing value of the parameter. If the first non-whitespace character in the parameter is a '*', set prefix to
a '*' and sep to '\n'. For line-break lists, set prefix to empty string and sep to '<br />'.
Category is appended to the end of the returned value only for pages in article space.
Inputs:
prefix – a string of characters that precede the error message span; typically '' and '*'
message – the error message to be displayed; goes inside the span
sep – a string of characters that separates the span from the parameter value; typically '\n' and '<br />'
param_val – the unmodified parameter value
showerrs – a boolean, true to display the error message text
]]
local function list_error (prefix, message, sep, param_val, showerrs)
local err_msg = '%s<span style="font-size:100%%" class="error">list error: %s ([[:Category:WPSHIPS:Infobox list errors|help]])</span>%s%s%s';
local category = '';
if 0 == mw.title.getCurrentTitle().namespace then -- only categorize pages in article space
category = '[[Category:WPSHIPS:Infobox list errors]]';
end
if true == showerrs then
return string.format (err_msg, prefix, message, sep, param_val, category); -- put it all together
else
return param_val .. category;
end
end
--[[--------------------------< U N B U L L E T E D _ L I S T >------------------------------------------------
Mediawiki:Common.css imposes limitations on plain, unbulleted lists. The template {{plainlist}} does not render this correctly:
{{plainlist|
*Item 1
*Item 2
**Item 2a
***Item 2a1
**Item 2b
*Item 3}}
The above renders without proper indents for items marked ** and ***.
If the list is not wrapped in {{plainlist}} then the above list is rendered with bullets which is contrary to the Infobox ship usage guide.
This code translates a bulleted list into an html unordered list:
<ul style="list-style:none; margin:0;">
<li>Name 1</li>
<li>Name 2</li>
<ul style="list-style:none">
<li>Subname 2a</li>
<ul style="list-style:none">
<li>Subname 2a1</li>
</ul>
<li>Subname 2b</li>
</ul>
<li>Name 3</li>
</ul>
There are rules:
1. The parameter value must begin with a splat but may have leading and trailing whitespace.
2. Each list item after the first must begin on a new line just as is required by normal bulleted lists.
3. When adding a sublevel, the number of splats may increase by one and never more. This is illegal:
*item
***item
When any of these rules are violated, unbulleted_list() returns the original text and adds the article
to Category:WPSHIPS:Infobox list errors. Error messaging in this function is somewhat sketchy so they are
disabled. After initial adoption, better error messaging could/should be implemented.
This function receives the content of one parameter:
{{#invoke:WPSHIPS utilities|unbulleted_list|{{{param|}}}}}
]]
local function _unbulleted_list (param)
local showerrs = true; -- set to false to hide error messages
local List_item_otag = '<li style="padding-left: .4em; text-indent: -.4em;">'; -- hanging indent markup; everything moves right with padding-left; first line moved left by neg indent
if nil == param:match ('^%s*%*') then -- parameter value must begin with a splat (ignoring leading white space)
if param:match ('<[%s/]*[Bb][Rr][%s/]*>') then -- if the parameter value has a list using variants of <br /> tag
return list_error ('', '<br /> list', '<br />', param, showerrs); -- return an error message with maintenance category
elseif param:match ('<div style="clear:') then
return list_error ('', '{{clear}} list', '<br />', param, showerrs); -- return an error message with maintenance category
elseif param:match ('.+\n%*') then -- if the parameter value has text followed by an unordered list
return list_error ('', 'mixed text and list', '<br />', param, showerrs); -- return an error message with maintenance category
end
return param; -- return the parameter as is
end
local item_table = mw.text.split (mw.text.trim (param), '\n'); -- trim white space from end then make a table of bulleted items by splitting on newlines
if 1 == #item_table then -- if only one bulleted item, no need for a list
return (item_table[1]:gsub ('^%*%s*', '')); -- trim off the splat and any following white space and done
end
if item_table[1]:match ('^%*%*+') then -- if first list item uses more than one splat, that's an error
return list_error ('*', 'too many * at start of list', '\n', param, showerrs); -- return an error message with maintenance category
end
local html_table = {}; -- table to hold the html output
local level = 1; -- used to indicate when a new <ul> is required
local splats = 0; -- number of splats that start each item in the list
local item = ''; -- the item text
table.insert (html_table, '<ul style="list-style:none; margin:0;">') -- this for first <ul> tag; sets no bullets and no indent
for _,v in ipairs (item_table) do
splats, item = v:match ('(%*+)%s*(.*)'); -- split the item into splats and item text
if nil == splats then -- nil if there is an extra line between items
return list_error ('*', 'list item missing markup', '\n', param, showerrs); -- return an error message with maintenance category
elseif '' == item then
return list_error ('*', 'empty list item', '\n', param, showerrs); -- return an error message with maintenance category
elseif item:match ('^[;:]') then -- if the list item is mixed unordered list / description list markup (*:)
return list_error ('*', 'mixed list type', '\n', param, showerrs); -- return an error message with maintenance category
end
splats = splats:len(); -- change string of splats into a number indicating how many splats there are
if splats == level then -- if at the same level as previous item
table.insert (html_table, List_item_otag .. item .. '</li>');
elseif splats == level + 1 then -- number of splats can only increase by one
level = splats; -- record the new level
table.insert (html_table, '<ul style="list-style: none">'); -- add a new sublist
table.insert (html_table, List_item_otag .. item .. '</li>'); -- and the item
elseif splats < level then -- from three splats to one splat for example
while splats < level do
table.insert (html_table, '</ul>'); -- close each sub <ul> until level and splats match
level = level - 1;
end
table.insert (html_table, List_item_otag .. item .. '</li>'); -- add the item
else -- jumping more than one level up – one splat to three splats for example – is an error
return list_error ('*', 'too many asterisks', '\n', param, showerrs); -- return an error message with maintenance category
end
end
while 0 < level do
table.insert (html_table, '</ul>'); -- close each <ul> until level counted down to zero
level = level - 1;
end
return table.concat (html_table, '\n'); -- return the list as a string
end
--[[--------------------------< U N B U L L E T E D _ L I S T >------------------------------------------------
external entry point
]]
local function unbulleted_list (frame)
return _unbulleted_list (frame.args[1])
end
--[=[-------------------------< _I N F O B O X _ S H I P _ F L A G >--------------------------------------------
Output of {{shipboxflag|USA}}:
[[File:Flag of the United States.svg|100x35px|alt=|link=]]
Image syntax:
[[File:Name|Type|Border|Location|Alignment|Size|link=Link|alt=Alt|Caption]]
This function standardizes the size of flag images in the infobox ship career header by simply overwriting the Size
parameter value in the Image wikilink with |100x28px. This size leave a 1px gap between the top and bottom of the flag image and
the header edge. A similar left-side gap of 2px is supplied by {{infobox ship career}}.
]=]
local function _infobox_ship_flag (image)
if image:match ('|[%s%dx]+px%s*') then -- is there a size positional parameter?
image = image:gsub('|[%s%dx]+px%s*', '%|100x28px'); -- overwrite it with |100x28px
else
return '<span style="font-size:100%" class="error">malformed flag image</span>'
end
return image; -- return the modified image
end
--[=[-------------------------< I N F O B O X _ S H I P _ F L A G >--------------------------------------------
external entry point
]=]
local function infobox_ship_flag (frame)
if not is_set (frame.args[1]) then -- if |Ship flag= not set
return ''; -- return empty string
end
return _infobox_ship_flag (frame.args[1]); -- return the modified image
end
--[=[-------------------------< C I T E _ D A N F S _ T I T L E >----------------------------------------------
This function attempts to render a DANFS article title in more or less proper (per Wikipedia) format for the
template {{cite danfs}}. DANFS titles typically take one of four forms:
<ship name> <disambiguator> <hull number>
<ship name> <hull number>
<ship name> <disambiguator>
<ship name>
Here, we extract the various parts, italicize the ship name and reassemble for use by the cite danfs |title= parameter.
To call this function:
|title={{#invoke:WPSHIPS utilities|cite_danfs_title|{{{title}}}}}
]=]
local function cite_danfs_title (frame)
local name;
local disambiguator;
local hullnum;
if not is_set (frame.args[1]) then -- if |title= not set
return ''; -- return empty string
end
name, disambiguator, hullnum = frame.args[1]:match ('(.-)( [XVI]+)( %([^%)]+%))$');
if not (name and disambiguator and hullnum) then
disambiguator = ''; -- empty string for concatenation
name, hullnum = frame.args[1]:match ('(.-)( %([^%)]+%))$');
if not (name and hullnum) then
hullnum = ''; -- empty string for concatenation
name, disambiguator = frame.args[1]:match ('(.-)( [XVI]+)$');
if not (name and disambiguator) then
disambiguator = '';
name = frame.args[1]; -- just a name or something we don't recognize
end
end
end
return table.concat ({"''", name, "''", disambiguator, hullnum}); -- reassemble and done
end
--[[--------------------------< S Y N O N Y M _ C H E C K >----------------------------------------------------
support function for infoboxen functions
there are a handful of infoboxen parameters that are synonymous pairs. This function is called to see if both
of the parameters in a synonymous pair have been assigned a value. When both have assigned values, each gets an
error message appended to it. Most of the synonymous pairs are UK Emglish v US English so the variable names
<args_t> table of template parameters and values
<uk_param> UK English parameter name
<us_param> US English parameter name
<error_flag> boolean that this function sets true when both of a pair are set; controls addition of maint category
]]
local function synonym_check (args_t, uk_param, us_param, error_flag)
if args_t[uk_param] and args_t[us_param] then
args_t[uk_param] = args_t[uk_param] .. error_msg_make ('synonymous'); -- both are set so append error message with category
args_t[us_param] = args_t[us_param] .. error_msg_make ('synonymous', nil, nil, true); -- but append error message without category
return true; -- inform the calling function that it needs to emit maint category
end
return error_flag; -- no match so return unmodified <error_flag>
end
--[[--------------------------< L I N E _ I T E M S >----------------------------------------------------------
support function for infoboxen functions
This function handles all infobox ship parameters that are 'line items' (label followed by value) because all
of these sorts of parameters are rendered with exacty the same formatting.
params_t{} is a table of tables where the params_t{} keys are the template's parameter names. The params_t{}
values are sequences where [1] is an index number that defines where in the rendering the label/value pair is
positioned and [2] is the label that will be rendered when the parameter has a value.
This indexing is used because params_t{} is not a sequence and because pairs() does not necessarily return the
'next' k/v pair.
This function spins through params_t{} and writes html for parameters that have assigned values into temp_t{}
according to the 'index' value in the associated sequance table. When parameters are missing or empty, this
function writes an empty string into the associated location in lines_t{} so that lines_t{} can be concatenated
into a string value that is returned to the calling function.
args_t is the arguments table from the template frame.
]]
local function line_items (args_t, params_t)
local lines_t = {}; -- a sequence table of rendered label/value html lines; one for each key in params_t{}
for k, v in pairs (params_t) do -- k is templat e parameter name; v is a sequence table with index and associated label
local temp_t = {} -- initialize/reinitialize for next line item
if not args_t[k] then -- if no assigned value then
lines_t[v[1]] = ''; -- set to empty string for concatenation
else
table.insert (temp_t, '<tr style="vertical-align:top;"><td style="font-weight: bold">'); -- open the line item row and cell
table.insert (temp_t, v[2]); -- add parameter's label text
table.insert (temp_t, '</td><td>'); -- close that cell and open the parameter value cell
table.insert (temp_t, _unbulleted_list (args_t[k])); -- add the parameter's value; formatted as unordered list if appropriate
table.insert (temp_t, '</td></tr>\n'); -- close that cell and this row
end
lines_t[v[1]] = table.concat (temp_t); -- concatenate and put the line item in the lines sequence table at the index position
end
return table.concat (lines_t); -- make a big string of line items and done
end
--[[--------------------------< I N F O B O X _ S H I P _ C A R E E R >----------------------------------------
implements {{Infobox ship career}}
{{#invoke:WPSHIPS utilities|infobox_ship_career}}
]]
local function infobox_ship_career (frame)
local args_t = get_args (frame); -- get a table of all parameters in the template call
local html_out_t = {}; -- html table text goes here
local error_flag = false; -- controls emission of maint category when synonymous parameters are both set
args_t['Hide header'] = args_t['Hide header'] and args_t['Hide header']:lower(); -- set to lowercase if set
error_flag = synonym_check (args_t, 'Ship stricken', 'Ship struck', error_flag); -- error if both synonymous parameters set
error_flag = synonym_check (args_t, 'Ship honours', 'Ship honors', error_flag);
if 'yes' ~= args_t['Hide header'] then -- |Hide header=yes then no header
if not ('title' == args_t['Hide header']) then -- |Hide header=title then no title bar
table.insert (html_out_t, '<tr><th colspan="2" ');
table.insert (html_out_t, styles.header_bar); -- style from WPMILHIST
table.insert (html_out_t, '>History</th></tr>\n');
end
if args_t['Ship country'] and args_t['Ship flag'] then
table.insert (html_out_t, '<tr><th height="30" colspan="2" style="background-color:#B0C4DE;text-align:left;padding-left:2px;vertical-align:middle;font-size:110%;">');
table.insert (html_out_t, _infobox_ship_flag (args_t['Ship flag']));
table.insert (html_out_t, '<span style="padding-left:1em">');
table.insert (html_out_t, args_t['Ship country']);
table.insert (html_out_t, '</span>');
table.insert (html_out_t, '</th></tr>\n');
elseif args_t['Ship country'] then
table.insert (html_out_t, '<tr><th height="30" colspan="2" style="background-color:#B0C4DE;text-align:center;vertical-align:middle;font-size:110%;">');
table.insert (html_out_t, args_t['Ship country']);
table.insert (html_out_t, '</th></tr>\n');
elseif args_t['Ship flag'] then
table.insert (html_out_t, '<tr><th height="30" colspan="2" style="background-color:#B0C4DE;padding-left:2px;">');
table.insert (html_out_t, _infobox_ship_flag (args_t['Ship flag']));
table.insert (html_out_t, '</th></tr>\n');
end
end
table.insert (html_out_t, line_items (args_t, data.infobox_career_params_t)); -- add all of the rest of the template's html
--mw.logObject (table.concat (html_out_t));
return table.concat (html_out_t); -- make a big string and done
end
--[[--------------------------< I N F O B O X _ S H I P _ C H A R A C T E R I S T I C S >----------------------
implements {{Infobox ship characteristics}}
{{#invoke:WPSHIPS utilities|infobox_ship_characteristics}}
]]
local function infobox_ship_characteristics (frame)
local args_t = get_args (frame); -- get a table of all parameters in the template call
local html_out_t = {}; -- html table text goes here
local error_flag = false; -- controls emission of maint category when synonymous parameters are both set
args_t['Hide header'] = args_t['Hide header'] and args_t['Hide header']:lower(); -- set to lowercase if set
error_flag = synonym_check (args_t, 'Ship armour', 'Ship armor', error_flag); -- error if both synonymous parameters set
error_flag = synonym_check (args_t, 'Ship draught', 'Ship draft', error_flag);
if 'yes' ~= args_t['Hide header'] then -- |Hide header=yes then no header
table.insert (html_out_t, '<tr><th colspan="2" ');
table.insert (html_out_t, styles.header_bar); -- style from WPMILHIST
table.insert (html_out_t, '>General characteristics');
if args_t['Header caption'] then
table.insert (html_out_t, ' ');
table.insert (html_out_t, args_t['Header caption']);
end
table.insert (html_out_t, '</th></tr>\n');
end
table.insert (html_out_t, line_items (args_t, data.infobox_characteristics_params_t)); -- add all of the rest of the template's html
--mw.logObject (table.concat (html_out_t));
return table.concat (html_out_t); -- make a big string and done
end
--[[--------------------------< I N F O B O X _ S H I P _ C L A S S _ O V E R V I E W >------------------------
implements {{Infobox ship class overview}}
{{#invoke:WPSHIPS utilities|infobox_ship_class_overview}}
]]
local function infobox_ship_class_overview (frame)
local args_t = get_args (frame); -- get a table of all parameters in the template call
local html_out_t = {}; -- html table text goes here
args_t['Hide header'] = args_t['Hide header'] and args_t['Hide header']:lower();
if 'yes' ~= args_t['Hide header'] then -- |Hide header=yes then no header
table.insert (html_out_t, '<tr><th colspan="2" ');
table.insert (html_out_t, styles.header_bar); -- style from WPMILHIST
table.insert (html_out_t, '>Class overview</th></tr>\n');
end
table.insert (html_out_t, line_items (args_t, data.infobox_class_overview_params_t)); -- add all of the rest of the template's html
--mw.logObject (table.concat (html_out_t));
return table.concat (html_out_t); -- make a big string and done
end
--[[--------------------------< I S _ P L I M S O L L _ F I L E N A M E >--------------------------------------
validate cite plimsoll |filename=<filename>
<filename> format is: YYvssss.pdf where
YY - least significant two digits of four-digit first year in a two-year range
30 -> 1930–1931
allowed values are all integers between and including 30–45
v - a single lowercase letter 'a' or 'b'
'a' -> volume I
'b' -> volume II
ssss - scan number begins with 0001
odd numbered scans have English headings
even numbered scans have French headings
{{#invoke:WPSHIPS utilities|is_plimsoll_filename|{{{filename}}}}}
]]
local function is_plimsoll_filename (frame)
local args_t = get_args (frame); -- get a table of all parameters in the invoke
local year, volume, scan;
if args_t[1] then -- this to avoid script errors when args_t[1] missing
year, volume, scan = args_t[1]:match ('(%d%d)(%l)(%d%d%d%d)%.[Pp][Dd][Ff]'); -- get the various parts
end
if not year then return nil end -- nil when no match so we're done
year = tonumber (year);
scan = tonumber (scan);
if (30 > year) or (45 < year) then return nil end
if not (('a' == volume) or ('b' == volume)) then return nil end
if (1 > scan) then return nil end
return true;
end
--[[--------------------------< S E T _ P L I M S O L L _ D A T E >--------------------------------------------
create two-year range from first two digits in |filename=<filename>
30 -> 1930–1931
{{#invoke:WPSHIPS utilities|set_plimsoll_date|{{{filename}}}}}
]]
local function set_plimsoll_date (frame)
local args_t = get_args (frame); -- get a table of all parameters in the invoke
if not args_t[1] then
return nil;
end
local year = args_t[1]:match ('(%d%d)%l%d%d%d%d'); -- get the intial year
year = 1900 + tonumber (year); -- make it a four-digit year
return string.format ('%d–%d', year, year + 1); -- and then add one for the second year in the range
end
--[[--------------------------< S E T _ P L I M S O L L _ S U B T I T L E >-----------------------------------1
used in {{cite plimsoll}}
return appropriate subtitle string given |subtitle=<keyword>
{{#invoke:WPSHIPS utilities|set_plimsoll_subtitle|{{{subtitle}}}}}
]]
local function set_plimsoll_subtitle (frame)
local subtitle = get_args (frame)[1]; -- get the subtitle parameter
if not subtitle then
return nil;
end
if not data.subtitles_t[subtitle] then
return ': ' .. subtitle; -- not predefined so return whatever |subtitle= holds with leading ': '
end
return ': ' .. data.subtitles_t[subtitle]; -- return predefined subtitle with leading ': '
end
--[[--------------------------< S E T _ P L I M S O L L _ U R L >----------------------------------------------
create plimsoll url from |filename=<filename>
{{#invoke:WPSHIPS utilities|set_plimsoll_url|{{{filename}}}}}
]]
local function set_plimsoll_url (frame)
local args_t = get_args (frame); -- get a table of all parameters in the invoke
if args_t[1] then
return string.format ('https://plimsoll.southampton.gov.uk/shipdata/pdfs/%s/%s',
args_t[1]:match ('(%d%d)%l%d%d%d%d'), -- get the year path portion from <filename>
args_t[1]); -- append <filename> onto the end, and done
end
end
--[[--------------------------< S C L A S S >------------------------------------------------------------------
implements {{sclass}} and {{sclass2}}
{{#invoke:WPSHIPS utilities|sclass}}
]]
local function sclass (frame)
local args_t = get_args (frame);
local parent = frame:getParent();
local template = parent:getTitle():gsub ('^Template:', ''):lower(); -- get the name of the template that called this module (includes namespace so strip that)
local class_name = args_t[1]; -- names to make it easier to understand
local ship_type = args_t[2];
local format = args_t[3];
local ship_type_dab = args_t[4];
local class_name_dab = args_t[5];
local no_cat = 'yes' == args_t['no-cat']; -- make a boolean
if not class_name then -- when omitted, abandon with error message
return error_msg_make ('missing', template, 'class name', no_cat);
end
if not ship_type then -- when omitted, abandon with error message
return error_msg_make ('missing', template, 'ship type', no_cat);
end
if format then
if tonumber (format) then -- if <format> has a value that is a number
format = tonumber (format); -- make it a number for comparisons
if 5 < format then -- is <format> outside of allowed range
return error_msg_make ('format', template, format, no_cat);
end
else -- <format> could not be converted to a number
return error_msg_make ('format', template, format, no_cat);
end
end
local out_t = {}; -- output goes here
table.insert (out_t, '[['); -- open the wikilink
table.insert (out_t, class_name); -- build the wikilink to the class article
table.insert (out_t, '-class ');
table.insert (out_t, ship_type); -- add ship type
if class_name_dab then -- when class article is disambiguated
table.insert (out_t, ' ('); -- add the disambiguator
table.insert (out_t, class_name_dab);
table.insert (out_t, ')');
end
table.insert (out_t, '|');
if 'sclass' == template:gsub ('/sandbox', '') then -- strip '/sandbox' if present; class named for a member of the class
table.insert (out_t, '\'\''); -- class name is italicized
table.insert (out_t, class_name);
table.insert (out_t, '\'\'');
else
table.insert (out_t, class_name); -- class name is a common attribute; plain text
end
if not format or (3 == format) then -- when format is omitted, same as format #3
table.insert (out_t, '-class]] [['); -- open ship-type wikilink
if ship_type_dab then -- when ship-type article is disambiguated
table.insert (out_t, ship_type); -- add ship type
table.insert (out_t, ' ('); -- and the disambiguator
table.insert (out_t, ship_type_dab);
table.insert (out_t, ')|'); -- dab is not displayed so insert a pipe and
end
table.insert (out_t, ship_type); -- add ship type
table.insert (out_t, ']]'); -- close ship-type wikilink
end
if 0 == format then -- no separate ship-type wikilink
table.insert (out_t, '-class]]');
end
if 1 == format then -- no separate ship-type wikilink
table.insert (out_t, '-class ');
table.insert (out_t, ship_type);
table.insert (out_t, ']]');
end
if 2 == format then -- ship-type is not wikilinked
table.insert (out_t, '-class]] ');
table.insert (out_t, ship_type);
end
if 4 == format then -- noun form; no ship type
table.insert (out_t, ' class]]');
end
if 5 == format then -- class name only; no '-class' annotation
table.insert (out_t, ']]');
end
return table.concat (out_t);
end
--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]
return {
cite_danfs_title = cite_danfs_title, -- external entry points for templates and invokes
hnsa = hnsa,
infobox_ship_career = infobox_ship_career,
infobox_ship_characteristics = infobox_ship_characteristics,
infobox_ship_class_overview = infobox_ship_class_overview,
infobox_ship_flag = infobox_ship_flag,
is_plimsoll_filename = is_plimsoll_filename,
navsource = navsource,
sclass = sclass,
set_plimsoll_subtitle = set_plimsoll_subtitle,
set_plimsoll_date = set_plimsoll_date,
set_plimsoll_url = set_plimsoll_url,
ship = ship, -- experiment
ship_name_format = ship_name_format,
unbulleted_list = unbulleted_list,
_infobox_ship_flag = _infobox_ship_flag, -- external entry points from another module
_ship_name_format = do_ship_name_format,
_synonym_check = synonym_check,
_unbulleted_list = _unbulleted_list,
}
c8c09d011a47c7ce86b4fd1cc3c01ec78db4e520
Module:Shortcut/styles.css
828
141
285
2023-03-14T15:53:59Z
w>Izno
0
Undid revision 1144571295 by [[Special:Contributions/TheDJ|TheDJ]] ([[User talk:TheDJ|talk]]) I'm sorry, that's not what we discussed or agreed to
text
text/plain
/* {{pp-template}} */
.module-shortcutboxplain {
float: right;
margin: 0 0 0 1em;
border: 1px solid #aaa;
background: #fff;
padding: 0.3em 0.6em 0.2em 0.6em;
text-align: center;
font-size: 85%;
}
.module-shortcutboxleft {
float: left;
margin: 0 1em 0 0;
}
.module-shortcutlist {
display: inline-block;
border-bottom: 1px solid #aaa;
margin-bottom: 0.2em;
}
.module-shortcutboxplain ul {
font-weight: bold;
}
.module-shortcutanchordiv {
position: relative;
top: -3em;
}
li .module-shortcutanchordiv {
float: right; /* IE/Edge in list items */
}
.mbox-imageright .module-shortcutboxplain {
padding: 0.4em 1em 0.4em 1em;
line-height: 1.3;
margin: 0;
}
ccf3877e4b14726147d3b1d8a297fbecacdb2cf8
Module:Sidebar/configuration
828
43
89
2023-03-14T22:32:24Z
Template>Izno
0
add hlist and plainlist_templatestyles keys
Scribunto
text/plain
return {
i18n = {
child_yes = 'yes',
float_none = 'none',
float_left = 'left',
wrap_true = 'true',
navbar_none = 'none',
navbar_off = 'off',
default_list_title = 'List',
title_not_to_add_navbar = 'Template:Sidebar',
collapse_title_not_to_add_navbar = 'Template:Sidebar with collapsible lists',
templatestyles = 'Module:Sidebar/styles.css',
hlist_templatestyles = 'Hlist/styles.css',
plainlist_templatestyles = 'Plainlist/styles.css',
category = {
child = '[[Category:Pages using sidebar with the child parameter]]',
conversion = '[[Category:Sidebars with styles needing conversion]]'
},
pattern = {
collapse_sandbox = '/sandbox$',
sandbox = '/sandbox$',
subgroup = 'sidebar%-subgroup',
style_conversion = 'style$',
uncategorized_conversion_titles = {
'/[Ss]andbox',
'/[Tt]estcases',
'/[Dd]oc$'
}
},
class = {
sidebar = 'sidebar',
subgroup = 'sidebar-subgroup',
collapse = 'sidebar-collapse',
float_none = 'sidebar-none',
float_left = 'sidebar-left',
wraplinks = 'nowraplinks',
outer_title = 'sidebar-outer-title',
top_image = 'sidebar-top-image',
top_caption = 'sidebar-top-caption',
pretitle = 'sidebar-pretitle',
pretitle_with_top_image = 'sidebar-pretitle-with-top-image',
title = 'sidebar-title',
title_with_pretitle = 'sidebar-title-with-pretitle',
image = 'sidebar-image',
caption = 'sidebar-caption',
above = 'sidebar-above',
heading = 'sidebar-heading',
content = 'sidebar-content',
content_with_subgroup = 'sidebar-content-with-subgroup',
below = 'sidebar-below',
navbar = 'sidebar-navbar',
list = 'sidebar-list',
list_title = 'sidebar-list-title',
list_title_centered = 'sidebar-list-title-c',
list_content = 'sidebar-list-content'
}
}
}
dc2a980ac2162a898f7c21e6d6ba7e994dfeb315
Module:Sidebar
828
42
87
2023-03-14T22:35:53Z
Template>Izno
0
move these items to config, discovered during work at meta
Scribunto
text/plain
require('strict')
local cfg = mw.loadData('Module:Sidebar/configuration')
local p = {}
local getArgs = require('Module:Arguments').getArgs
--[[
Categorizes calling templates and modules with a 'style' parameter of any sort
for tracking to convert to TemplateStyles.
TODO after a long cleanup: Catch sidebars in other namespaces than Template and Module.
TODO would probably want to remove /log and /archive as CS1 does
]]
local function categorizeTemplatesWithInlineStyles(args)
local title = mw.title.getCurrentTitle()
if title.namespace ~= 10 and title.namespace ~= 828 then return '' end
for _, pattern in ipairs (cfg.i18n.pattern.uncategorized_conversion_titles) do
if title.text:match(pattern) then return '' end
end
for key, _ in pairs(args) do
if mw.ustring.find(key, cfg.i18n.pattern.style_conversion) or key == 'width' then
return cfg.i18n.category.conversion
end
end
end
--[[
For compatibility with the original {{sidebar with collapsible lists}}
implementation, which passed some parameters through {{#if}} to trim their
whitespace. This also triggered the automatic newline behavior.
]]
-- See ([[meta:Help:Newlines and spaces#Automatic newline]])
local function trimAndAddAutomaticNewline(s)
s = mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1")
if mw.ustring.find(s, '^[#*:;]') or mw.ustring.find(s, '^{|') then
return '\n' .. s
else
return s
end
end
--[[
Finds whether a sidebar has a subgroup sidebar.
]]
local function hasSubgroup(s)
if mw.ustring.find(s, cfg.i18n.pattern.subgroup) then
return true
else
return false
end
end
local function has_navbar(navbar_mode, sidebar_name)
return navbar_mode ~= cfg.i18n.navbar_none and
navbar_mode ~= cfg.i18n.navbar_off and
(
sidebar_name or
mw.getCurrentFrame():getParent():getTitle():gsub(cfg.i18n.pattern.sandbox, '') ~=
cfg.i18n.title_not_to_add_navbar
)
end
local function has_list_class(args, htmlclass)
local patterns = {
'^' .. htmlclass .. '$',
'%s' .. htmlclass .. '$',
'^' .. htmlclass .. '%s',
'%s' .. htmlclass .. '%s'
}
for arg, value in pairs(args) do
if type(arg) == 'string' and mw.ustring.find(arg, 'class') then
for _, pattern in ipairs(patterns) do
if mw.ustring.find(args[arg] or '', pattern) then
return true
end
end
end
end
return false
end
-- there are a lot of list classes in the wild, so we add their TemplateStyles
local function add_list_styles(args)
local frame = mw.getCurrentFrame()
local function add_list_templatestyles(htmlclass, templatestyles)
if has_list_class(args, htmlclass) then
return frame:extensionTag{
name = 'templatestyles', args = { src = templatestyles }
}
else
return ''
end
end
local plainlist_styles = add_list_templatestyles('plainlist', cfg.i18n.plainlist_templatestyles)
local hlist_styles = add_list_templatestyles('hlist', cfg.i18n.hlist_templatestyles)
-- a second workaround for [[phab:T303378]]
-- when that issue is fixed, we can actually use has_navbar not to emit the
-- tag here if we want
if has_navbar(args.navbar, args.name) and hlist_styles == '' then
hlist_styles = frame:extensionTag{
name = 'templatestyles', args = { src = cfg.i18n.hlist_templatestyles}
}
end
-- hlist -> plainlist is best-effort to preserve old Common.css ordering. [hlist_note]
return hlist_styles .. plainlist_styles
end
-- work around [[phab:T303378]]
-- for each arg: find all the templatestyles strip markers, insert them into a
-- table. then remove all templatestyles markers from the arg
local function move_hiding_templatestyles(args)
local gfind = string.gfind
local gsub = string.gsub
local templatestyles_markers = {}
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
for k, arg in pairs(args) do
for marker in gfind(arg, strip_marker_pattern) do
table.insert(templatestyles_markers, marker)
end
args[k] = gsub(arg, strip_marker_pattern, '')
end
return templatestyles_markers
end
--[[
Main sidebar function. Takes the frame, args, and an optional collapsibleClass.
The collapsibleClass is and should be used only for sidebars with collapsible
lists, as in p.collapsible.
]]
function p.sidebar(frame, args, collapsibleClass)
if not args then
args = getArgs(frame)
end
local hiding_templatestyles = table.concat(move_hiding_templatestyles(args))
local root = mw.html.create()
local child = args.child and mw.text.trim(args.child) == cfg.i18n.child_yes
root = root:tag('table')
if not child then
root
:addClass(cfg.i18n.class.sidebar)
-- force collapsibleclass to be sidebar-collapse otherwise output nothing
:addClass(collapsibleClass == cfg.i18n.class.collapse and cfg.i18n.class.collapse or nil)
:addClass('nomobile')
:addClass(args.float == cfg.i18n.float_none and cfg.i18n.class.float_none or nil)
:addClass(args.float == cfg.i18n.float_left and cfg.i18n.class.float_left or nil)
:addClass(args.wraplinks ~= cfg.i18n.wrap_true and cfg.i18n.class.wraplinks or nil)
:addClass(args.bodyclass or args.class)
:css('width', args.width or nil)
:cssText(args.bodystyle or args.style)
if args.outertitle then
root
:tag('caption')
:addClass(cfg.i18n.class.outer_title)
:addClass(args.outertitleclass)
:cssText(args.outertitlestyle)
:wikitext(args.outertitle)
end
if args.topimage then
local imageCell = root:tag('tr'):tag('td')
imageCell
:addClass(cfg.i18n.class.top_image)
:addClass(args.topimageclass)
:cssText(args.topimagestyle)
:wikitext(args.topimage)
if args.topcaption then
imageCell
:tag('div')
:addClass(cfg.i18n.class.top_caption)
:cssText(args.topcaptionstyle)
:wikitext(args.topcaption)
end
end
if args.pretitle then
root
:tag('tr')
:tag('td')
:addClass(args.topimage and cfg.i18n.class.pretitle_with_top_image
or cfg.i18n.class.pretitle)
:addClass(args.pretitleclass)
:cssText(args.basestyle)
:cssText(args.pretitlestyle)
:wikitext(args.pretitle)
end
else
root
:addClass(cfg.i18n.class.subgroup)
:addClass(args.bodyclass or args.class)
:cssText(args.bodystyle or args.style)
end
if args.title then
if child then
root
:wikitext(args.title)
else
root
:tag('tr')
:tag('th')
:addClass(args.pretitle and cfg.i18n.class.title_with_pretitle
or cfg.i18n.class.title)
:addClass(args.titleclass)
:cssText(args.basestyle)
:cssText(args.titlestyle)
:wikitext(args.title)
end
end
if args.image then
local imageCell = root:tag('tr'):tag('td')
imageCell
:addClass(cfg.i18n.class.image)
:addClass(args.imageclass)
:cssText(args.imagestyle)
:wikitext(args.image)
if args.caption then
imageCell
:tag('div')
:addClass(cfg.i18n.class.caption)
:cssText(args.captionstyle)
:wikitext(args.caption)
end
end
if args.above then
root
:tag('tr')
:tag('td')
:addClass(cfg.i18n.class.above)
:addClass(args.aboveclass)
:cssText(args.abovestyle)
:newline() -- newline required for bullet-points to work
:wikitext(args.above)
end
local rowNums = {}
for k, v in pairs(args) do
k = '' .. k
local num = k:match('^heading(%d+)$') or k:match('^content(%d+)$')
if num then table.insert(rowNums, tonumber(num)) end
end
table.sort(rowNums)
-- remove duplicates from the list (e.g. 3 will be duplicated if both heading3
-- and content3 are specified)
for i = #rowNums, 1, -1 do
if rowNums[i] == rowNums[i - 1] then
table.remove(rowNums, i)
end
end
for i, num in ipairs(rowNums) do
local heading = args['heading' .. num]
if heading then
root
:tag('tr')
:tag('th')
:addClass(cfg.i18n.class.heading)
:addClass(args.headingclass)
:addClass(args['heading' .. num .. 'class'])
:cssText(args.basestyle)
:cssText(args.headingstyle)
:cssText(args['heading' .. num .. 'style'])
:newline()
:wikitext(heading)
end
local content = args['content' .. num]
if content then
root
:tag('tr')
:tag('td')
:addClass(hasSubgroup(content) and cfg.i18n.class.content_with_subgroup
or cfg.i18n.class.content)
:addClass(args.contentclass)
:addClass(args['content' .. num .. 'class'])
:cssText(args.contentstyle)
:cssText(args['content' .. num .. 'style'])
:newline()
:wikitext(content)
:done()
-- Without a linebreak after the </td>, a nested list like
-- "* {{hlist| ...}}" doesn't parse correctly.
:newline()
end
end
if args.below then
root
:tag('tr')
:tag('td')
:addClass(cfg.i18n.class.below)
:addClass(args.belowclass)
:cssText(args.belowstyle)
:newline()
:wikitext(args.below)
end
if not child and has_navbar(args.navbar, args.name) then
root
:tag('tr')
:tag('td')
:addClass(cfg.i18n.class.navbar)
:cssText(args.navbarstyle)
:wikitext(require('Module:Navbar')._navbar{
args.name,
mini = 1,
fontstyle = args.navbarfontstyle
})
end
local base_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = cfg.i18n.templatestyles }
}
local templatestyles = ''
if args['templatestyles'] and args['templatestyles'] ~= '' then
templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['templatestyles'] }
}
end
local child_templatestyles = ''
if args['child templatestyles'] and args['child templatestyles'] ~= '' then
child_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['child templatestyles'] }
}
end
local grandchild_templatestyles = ''
if args['grandchild templatestyles'] and args['grandchild templatestyles'] ~= '' then
grandchild_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
}
end
return table.concat({
add_list_styles(args), -- see [hlist_note] above about ordering
base_templatestyles,
templatestyles,
child_templatestyles,
grandchild_templatestyles,
hiding_templatestyles,
tostring(root),
(child and cfg.i18n.category.child or ''),
categorizeTemplatesWithInlineStyles(args)
})
end
local function list_title(args, is_centered_list_titles, num)
local title_text = trimAndAddAutomaticNewline(args['list' .. num .. 'title']
or cfg.i18n.default_list_title)
local title
if is_centered_list_titles then
-- collapsible can be finicky, so provide some CSS/HTML to support
title = mw.html.create('div')
:addClass(cfg.i18n.class.list_title_centered)
:wikitext(title_text)
else
title = mw.html.create()
:wikitext(title_text)
end
local title_container = mw.html.create('div')
:addClass(cfg.i18n.class.list_title)
-- don't /need/ a listnumtitleclass because you can do
-- .templateclass .listnumclass .sidebar-list-title
:addClass(args.listtitleclass)
:cssText(args.basestyle)
:cssText(args.listtitlestyle)
:cssText(args['list' .. num .. 'titlestyle'])
:node(title)
:done()
return title_container
end
--[[
Main entry point for sidebar with collapsible lists.
Does the work of creating the collapsible lists themselves and including them
into the args.
]]
function p.collapsible(frame)
local args = getArgs(frame)
if not args.name and
frame:getParent():getTitle():gsub(cfg.i18n.pattern.collapse_sandbox, '') ==
cfg.i18n.collapse_title_not_to_add_navbar then
args.navbar = cfg.i18n.navbar_none
end
local contentArgs = {}
local is_centered_list_titles = false
if args['centered list titles'] and args['centered list titles'] ~= '' then
is_centered_list_titles = true
end
for k, v in pairs(args) do
local num = string.match(k, '^list(%d+)$')
if num then
local expand = args.expanded and
(args.expanded == 'all' or args.expanded == args['list' .. num .. 'name'])
local row = mw.html.create('div')
row
:addClass(cfg.i18n.class.list)
:addClass('mw-collapsible')
:addClass((not expand) and 'mw-collapsed' or nil)
:addClass(args['list' .. num .. 'class'])
:cssText(args.listframestyle)
:cssText(args['list' .. num .. 'framestyle'])
:node(list_title(args, is_centered_list_titles, num))
:tag('div')
:addClass(cfg.i18n.class.list_content)
:addClass('mw-collapsible-content')
-- don't /need/ a listnumstyleclass because you can do
-- .templatename .listnumclass .sidebar-list
:addClass(args.listclass)
:cssText(args.liststyle)
:cssText(args['list' .. num .. 'style'])
:wikitext(trimAndAddAutomaticNewline(args['list' .. num]))
contentArgs['content' .. num] = tostring(row)
end
end
for k, v in pairs(contentArgs) do
args[k] = v
end
return p.sidebar(frame, args, cfg.i18n.class.collapse)
end
return p
71fe765846593e025ca2f94371315e9dbb5bb4d2
Template:Div col/styles.css
10
46
95
2023-03-29T18:11:31Z
Template>Jonesey95
0
Attempt to copy plainlist class from [[MediaWiki:Common.css]]. I don't know if this actually works.
text
text/plain
/* {{pp|small=yes}} */
.div-col {
margin-top: 0.3em;
column-width: 30em;
}
.div-col-small {
font-size: 90%;
}
.div-col-rules {
column-rule: 1px solid #aaa;
}
/* Reset top margin for lists in div col */
.div-col dl,
.div-col ol,
.div-col ul {
margin-top: 0;
}
/* Avoid elements breaking between columns
See also Template:No col break */
.div-col li,
.div-col dd {
page-break-inside: avoid; /* Removed from CSS in favor of break-inside c. 2020 */
break-inside: avoid-column;
}
/* Unbulleted lists */
.plainlist ol,
.plainlist ul {
line-height: inherit;
list-style: none;
margin: 0;
}
.plainlist ol li,
.plainlist ul li {
margin-bottom: 0;
}
76c2c0a042b9164cff638cd44af5ab129702c141
Help:Infobox/user style
12
72
147
2023-04-03T14:00:08Z
Template>Maddy from Celeste
0
blatant self-promotion
wikitext
text/x-wiki
{{{heading|
==Infoboxes and user style ==
}}}
Users can have [[WP:User style|user CSS]] that hides<!--, moves, or makes collapsible--> any infoboxes in their own browsers.
To hide all infoboxes, add the following to [[Special:MyPage/common.css]] (for all [[WP:Skin|skins]], or [[Special:MyPage/skin.css]] for just the current skin), on a line by itself:
<syntaxhighlight lang="css">div.mw-parser-output .infobox { display: none; }</syntaxhighlight>
Alternatively, you can add the following code to [[Special:MyPage/common.js|your common.js]] or into a browser user script that is executed by an extension like [[Greasemonkey]]:
<syntaxhighlight lang="js">$('.infobox').hide();</syntaxhighlight>
Be aware that although{{#if:{{{guideline|}}}||, per [[WP:Manual of Style/Infoboxes]],}} all information in an infobox ideally should also be found in the main body of an article, there isn't perfect compliance with this guideline. For example, the full taxonomic hierarchy in {{tlx|Taxobox}}, and the OMIM and other medical database codes of {{tlx|Infobox disease}} are often not found in the main article content. The infobox is also often the location of the most significant, even only, image in an article. There is a userscript which removes infoboxes but moves the images contained to separate thumbnails: [[User:Maddy from Celeste/disinfobox.js]].<!--
Needs Special:Mypage/common.js options for:
* Making infoboxes collapsible
** Making them auto-collapsed
* Moving infoboxes to bottom of page
--><noinclude>
{{Documentation|content=
This documentation snippet is transcluded at [[Help:Infobox]], [[Template:Infobox/doc]], [[WP:Customisation#Hiding specific messages]], [[Help:User style]], [[WP:Manual of Style/Infoboxes]], and other places where this information is relevant.
As a template, this snippet takes a {{para|heading}} parameter to replace the level-2 <code>==Infoboxes and user style==</code> section heading code, as needed. E.g., for a <code>=== ... ===</code> level-3 heading: <code><nowiki>heading={{=}}{{=}}{{=}}Infoboxes and user style{{=}}{{=}}{{=}}</nowiki></code>
}}
</noinclude>
ba4dac68eb2bdc49a32f2a11b9afd52381bf06b5
Module:LuaCall
828
149
301
2023-04-04T19:01:48Z
w>Lemondoge
0
Modified code formatting
Scribunto
text/plain
local p={}
function p.main(frame)
local parent = frame.getParent(frame) or {}
local reserved_value = {}
local reserved_function, reserved_contents
for k, v in pairs(parent.args or {}) do
_G[k] = tonumber(v) or v -- transfer every parameter directly to the global variable table
end
for k, v in pairs(frame.args or {}) do
_G[k] = tonumber(v) or v -- transfer every parameter directly to the global variable table
end
--- Alas Scribunto does NOT implement coroutines, according to
--- http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#string.format
--- this will not stop us from trying to implement one single lousy function call
if _G[1] then
reserved_function, reserved_contents = mw.ustring.match(_G[1], "^%s*(%a[^%s%(]*)%(([^%)]*)%)%s*$")
end
if reserved_contents then
local reserved_counter = 0
repeat
reserved_counter = reserved_counter + 1
reserved_value[reserved_counter] = _G[mw.ustring.match(reserved_contents, "([^%,]+)")]
reserved_contents = mw.ustring.match(reserved_contents, "[^%,]+,(.*)$")
until not reserved_contents
end
local reserved_arraypart = _G
while mw.ustring.match(reserved_function, "%.") do
reserved_functionpart, reserved_function = mw.ustring.match(reserved_function, "^(%a[^%.]*)%.(.*)$")
reserved_arraypart = reserved_arraypart[reserved_functionpart]
end
local reserved_call = reserved_arraypart[reserved_function]
if type(reserved_call) ~= "function" then
return tostring(reserved_call)
else
reserved_output = {reserved_call(unpack(reserved_value))}
return reserved_output[reserved_return or 1]
end
end
local function tonumberOrString(v)
return tonumber(v) or v:gsub("^\\", "", 1)
end
local function callWithTonumberOrStringOnPairs(f, ...)
local args = {}
for _, v in ... do
table.insert(args, tonumberOrString(v))
end
return (f(unpack(args)))
end
--[[
------------------------------------------------------------------------------------
-- ipairsAtOffset
-- This is an iterator for arrays. It can be used like ipairs, but with
-- specified i as first index to iterate. i is an offset from 1
--
------------------------------------------------------------------------------------
--]]
local function ipairsAtOffset(t, i)
local f, s, i0 = ipairs(t)
return f, s, i0+i
end
local function get(s)
local G = _G; for _ in mw.text.gsplit(
mw.text.trim(s, '%s'), '%s*%.%s*'
) do
G = G[_]
end
return G
end
--[[
------------------------------------------------------------------------------------
-- call
--
-- This function is usually useful for debugging template parameters.
-- Prefix parameter with backslash (\) to force interpreting parameter as string.
-- The leading backslash will be removed before passed to Lua function.
--
-- Example:
-- {{#invoke:LuaCall|call|mw.log|a|1|2|3}} will return results of mw.log('a', 1, 2, 3)
-- {{#invoke:LuaCall|call|mw.logObject|\a|321|\321| \321 }} will return results of mw.logObject('a', 321, '321', ' \\321 ')
--
-- This example show the debugging to see which Unicode characters are allowed in template parameters,
-- {{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0061}}}} return 97
-- {{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0000}}}} return 65533
-- {{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0001}}}} return 65533
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0002}}}}}} return 0xfffd
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x007e}}}}}} return 0x007e
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x007f}}}}}} return 0x007f
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0080}}}}}} return 0x0080
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x00a0}}}}}} return 0x00a0
--
------------------------------------------------------------------------------------
--]]
function p.call(frame)
return callWithTonumberOrStringOnPairs(get(frame.args[1]),
ipairsAtOffset(frame.args, 1)
)
end
--local TableTools = require('Module:TableTools')
--[[
------------------------------------------------------------------------------------
-- get
--
-- Example:
-- {{#invoke:LuaCall|get| math.pi }} will return value of math.pi
-- {{#invoke:LuaCall|get|math|pi}} will return value of math.pi
-- {{#invoke:LuaCall|get| math |pi}} will return value of _G[' math '].pi
-- {{#invoke:LuaCall|get|_G| math.pi }} will return value of _G[' math.pi ']
-- {{#invoke:LuaCall|get|obj.a.5.c}} will return value of obj.a['5'].c
-- {{#invoke:LuaCall|get|obj|a|5|c}} will return value of obj.a[5].c
--
------------------------------------------------------------------------------------
--]]
function p.get(frame)
-- #frame.args always return 0, regardless of number of unnamed
-- template parameters, so check manually instead
if frame.args[2] == nil then
-- not do tonumber() for this args style,
-- always treat it as string,
-- so 'obj.1' will mean obj['1'] rather obj[1]
return get(frame.args[1])
else
local G = _G
for _, v in ipairs(frame.args) do
G = G[tonumberOrString(v)]
end
return G
end
end
--[[
------------------------------------------------------------------------------------
-- invoke
--
-- This function is used by Template:Invoke
--
------------------------------------------------------------------------------------
--]]
function p.invoke(frame)
local pframe, usedpargs = frame:getParent(), {}
-- get module and function names from parent args if not provided
local pfargs = setmetatable({frame.args[1], frame.args[2]}, {__index = table})
if not pfargs[1] then
pfargs[1], usedpargs[1] = pframe.args[1], true
if not pfargs[2] then
pfargs[2], usedpargs[2] = pframe.args[2], true
end
elseif not pfargs[2] then
pfargs[2], usedpargs[1] = pframe.args[1], true
end
-- repack sequential args
for i, v in ipairs(pframe.args) do
if not usedpargs[i] then
pfargs:insert(v)
usedpargs[i] = true
end
end
-- copy other args
for k, v in pairs(pframe.args) do
if not pfargs[k] and not usedpargs[k] then
pfargs[k], usedpargs[k] = v, true
end
end
-- #invoke off parent frame so the new frame has the same parent
return pframe:callParserFunction{name = '#invoke', args = pfargs}
end
return p
d6ec342627682bf90e61bbad921fcc6190f2e090
Template:Collapse top
10
102
207
2023-04-07T02:02:13Z
w>Izno
0
per tech news
wikitext
text/x-wiki
<div style="margin-left:{{{indent|0}}}"><!-- NOTE: width renders incorrectly if added to main STYLE section -->
{| <!-- Template:Collapse top --> class="mw-collapsible mw-archivedtalk {{<includeonly>safesubst:</includeonly>#if:{{{expand|{{{collapse|}}}}}}||mw-collapsed}} {{{class|}}}" style="background: {{{bg1|transparent}}}; text-align: left; border: {{{border|1px}}} solid {{{b-color|Silver}}}; margin: 0.2em auto auto; width:{{<includeonly>safesubst:</includeonly>#if:{{{width|}}}|{{{width}}}|100%}}; clear: {{{clear|both}}}; padding: 1px;"
|-
! style="background: {{{bg|#{{main other|F0F2F5|CCFFCC}}}}}; font-size:87%; padding:0.2em 0.3em; text-align:{{<includeonly>safesubst:</includeonly>#if:{{{left|}}}|left|{{<includeonly>safesubst:</includeonly>#if:{{{align|}}}|left|center}}}}; {{<includeonly>safesubst:</includeonly>#if:{{{fc|}}}|color: {{{fc}}};|}}" | <div style="font-size:115%;{{<includeonly>safesubst:</includeonly>#if:{{{left|}}}||margin:0 4em}}">{{{1|{{{title|{{{reason|{{{header|{{{heading|{{{result|Extended content}}}}}}}}}}}}}}}}}}</div>
{{<includeonly>safesubst:</includeonly>#if:{{{warning|{{{2|}}}}}}
|{{<includeonly>safesubst:</includeonly>!}}-
{{<includeonly>safesubst:</includeonly>!}} style="text-align:center; font-style:italic;" {{<includeonly>safesubst:</includeonly>!}} {{{2|The following is a closed discussion. {{strongbad|Please do not modify it.}} }}} }}
|-
| style="border: solid {{{border2|1px Silver}}}; padding: {{{padding|0.6em}}}; background: {{{bg2|White}}};" {{<includeonly>safesubst:</includeonly>!}}<noinclude>
{{lorem ipsum|3}}
{{Collapse bottom}}
{{Documentation}}
</noinclude>
247cc43d5198baf8804d0926529cbbdd7be91113
Template:Uses TemplateStyles
10
80
163
2023-04-18T22:22:16Z
Template>Grufo
0
Move the preview inside the documentation
wikitext
text/x-wiki
<includeonly>{{#invoke:Uses TemplateStyles|main}}</includeonly><noinclude>{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
60f2fc73c4d69b292455879f9fcb3c68f6c63c2a
Module:Convert/text
828
90
183
2023-04-19T04:48:47Z
w>Johnuniq
0
update from sandbox per [[Template talk:Convert#Module version 28]]
Scribunto
text/plain
-- Text used by Module:Convert for enwiki.
-- This is a separate module to simplify translation for use on another wiki.
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
-- Some units accept an SI prefix before the unit code, such as "kg" for kilogram.
local SIprefixes = {
-- The prefix field is what the prefix should be, if different from the prefix used.
['Q'] = { exponent = 30, name = 'quetta', },
['R'] = { exponent = 27, name = 'ronna', },
['Y'] = { exponent = 24, name = 'yotta', },
['Z'] = { exponent = 21, name = 'zetta', },
['E'] = { exponent = 18, name = 'exa' , },
['P'] = { exponent = 15, name = 'peta' , },
['T'] = { exponent = 12, name = 'tera' , },
['G'] = { exponent = 9, name = 'giga' , },
['M'] = { exponent = 6, name = 'mega' , },
['k'] = { exponent = 3, name = 'kilo' , },
['h'] = { exponent = 2, name = 'hecto', },
['da']= { exponent = 1, name = 'deca' , name_us = 'deka' },
['d'] = { exponent = -1, name = 'deci' , },
['c'] = { exponent = -2, name = 'centi', },
['m'] = { exponent = -3, name = 'milli', },
['μ'] = { exponent = -6, name = 'micro', }, -- key = 'GREEK SMALL LETTER MU' (U+03BC) utf-8 CE BC
['µ'] = { exponent = -6, name = 'micro', prefix = 'μ' }, -- key = 'MICRO SIGN' (U+00B5) utf-8 C2 B5
['u'] = { exponent = -6, name = 'micro', prefix = 'μ' }, -- not an SI prefix, but allow for people typing this
['n'] = { exponent = -9, name = 'nano' , },
['p'] = { exponent =-12, name = 'pico' , },
['f'] = { exponent =-15, name = 'femto', },
['a'] = { exponent =-18, name = 'atto' , },
['z'] = { exponent =-21, name = 'zepto', },
['y'] = { exponent =-24, name = 'yocto', },
['r'] = { exponent =-27, name = 'ronto', },
['q'] = { exponent =-30, name = 'quecto', },
}
-- Some units can be qualified with one of the following prefixes, when linked.
local customary_units = {
{ "US", link = "United States customary units" },
{ "U.S.", link = "United States customary units" },
{ "imperial", link = "Imperial units" },
{ "imp", link = "Imperial units" },
}
-- Names when using engineering notation (a prefix of "eN" where N is a number; example "e6km").
-- key = { "name", link = "article title", exponent = numeric_key_value }
-- If lk=on and link is defined, the name of the number will appear as a link.
local eng_scales = {
["3"] = { "thousand", exponent = 3 },
["6"] = { "million", exponent = 6 },
["9"] = { "billion", link = "1000000000 (number)", exponent = 9 },
["12"] = { "trillion", link = "1000000000000 (number)", exponent = 12 },
["15"] = { "quadrillion", link = "1000000000000000 (number)", exponent = 15 },
}
local all_categories = {
unit = "[[Category:Convert errors]]",
option = "[[Category:Convert errors]]",
warning = '[[Category:Convert invalid options]]',
tracking = '[[Category:Convert tracking]]',
}
-- For some error messages, the following puts the wanted style around
-- each unit code marked like '...%{ft%}...'.
local unitcode_regex = '%%([{}])'
local unitcode_replace = { ['{'] = '"', ['}'] = '"' } -- no longer need the more elaborate substitute used before 2013-09-28
-- All messages that may be displayed if a problem occurs.
local all_messages = {
-- Message format string: $1=title, $2=text, $3=category, $4=anchor.
-- Each displayed message starts with "Convert:" so can easily locate by searching article.
cvt_format = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[<i>[[Help:Convert messages#$4|<span title="Convert: $1">convert: $2</span>]]</i>]</sup>$3<span class="error"></span>',
cvt_format2 = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[[Help:Convert messages#$4|<span title="Convert: $1">$2</span>]]</sup>$3<span class="error"></span>',
cvt_format_preview = '<strong class="error">Error in convert: $1 [[Help:Convert messages#$4|(help)]]</strong>$3',
-- Each of following messages is a table:
-- { [1] = 'title', -- mouseover title text
-- [2] = 'text', -- link text displayed in article
-- [3] = 'category key', -- key to lookup category in all_categories
-- [4] = 'anchor', -- anchor for link to relevant section on help page
-- regex = gsub_regex,
-- replace = gsub_table,
-- } Mouseover title text Link text CatKey Anchor
cvt_bad_input = { 'input "$1" must be a number and unit' , 'invalid input' , 'option', 'invalid_input' },
cvt_bad_num = { 'Value "$1" must be a number' , 'invalid number' , 'option', 'invalid_number' },
cvt_big_prec = { 'Precision "$1" is too large' , 'precision too large' , 'option', 'precision_too_large' },
cvt_invalid_num = { 'Number has overflowed' , 'number overflow' , 'option', 'number_overflow' },
cvt_no_num = { 'Needs the number to be converted' , 'needs a number' , 'option', 'needs_number' },
cvt_no_num2 = { 'Needs another number for a range' , 'needs another number', 'option', 'needs_another_number' },
cvt_bad_altitude = { '"$1" needs an integer' , 'invalid altitude' , 'option', 'invalid_altitude' },
cvt_bad_frac = { '"$1" needs an integer above 1' , 'invalid fraction' , 'option', 'invalid_fraction' },
cvt_bad_prec = { 'Precision "$1" must be an integer' , 'invalid precision' , 'option', 'invalid_precision' },
cvt_bad_sigfig = { '"$1" needs a positive integer' , 'invalid sigfig' , 'option', 'invalid_sigfig' },
cvt_empty_option = { 'Ignored empty option "$1"' , 'empty option' , 'option', 'empty_option' },
cvt_deprecated = { 'Option "$1" is deprecated' , '*' , 'option', 'deprecated_option', format = 'cvt_format2', nowarn = true },
cvt_no_spell = { 'Spelling is not available' , 'bug, ask for help' , 'option', 'ask_for_help' },
cvt_unknown_option = { 'Ignored invalid option "$1"' , 'invalid option' , 'option', 'invalid_option' },
cvt_wd_fail = { 'Unable to access Wikidata' , 'wikidata problem' , 'option', 'wikidata_problem' },
cvt_bad_default = { 'Unit "$1" has an invalid default' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_bad_unit = { 'Unit "$1" is invalid here' , 'unit invalid here' , 'unit' , 'unit_invalid_here' },
cvt_no_default = { 'Unit "$1" has no default output unit' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_no_unit = { 'Needs name of unit' , 'needs unit name' , 'unit' , 'needs_unit_name' },
cvt_unknown = { 'Unit name "$1" is not known' , 'unknown unit' , 'unit' , 'unknown_unit' },
cvt_should_be = { '$1' , 'ambiguous unit' , 'unit' , 'ambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_mismatch = { 'Cannot convert "$1" to "$2"' , 'unit mismatch' , 'unit' , 'unit_mismatch' },
cvt_bug_convert = { 'Bug: Cannot convert between specified units', 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_lookup = { 'Unit "$1" is incorrectly defined' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
}
-- Text to join input value/unit with output value/unit.
local disp_joins = {
-- [1]=before output, [2]=after output, [3]=between outputs in a combination; default "; "
-- [wantname] gives default abbr=off
["or"] = { " or " , "" , " or ", wantname = true },
["sqbr-sp"] = { " [" , "]" },
["sqbr-nbsp"] = { " [" , "]" },
["comma"] = { ", " , "" , ", " },
["semicolon"] = { "; " , "" },
["slash-sp"] = { " / " , "" , wantname = true },
["slash-nbsp"] = { " / ", "" , wantname = true },
["slash-nosp"] = { "/" , "" , wantname = true },
["b"] = { " (" , ")" },
["(or)"] = { " (" , ")", " or " },
["br"] = { "<br />" , "" , wantname = true },
["br()"] = { "<br />(" , ")", wantname = true },
}
-- Text to separate values in a range.
local range_types = {
-- Specifying a table requires either:
-- * "off" and "on" values (for "abbr=off" and "abbr=on"), or
-- * "input" and "output" values (for LHS and RHS);
-- other fields are optional.
-- When "adj=on|abbr=off" applies, spaces in range text are replaced with hyphens.
-- With "exception = true", that also occurs with "adj=on|abbr=on".
-- If "adj" is defined here, that text (unchanged) is used with "adj=on".
["+"] = " + ",
[","] = ", ",
[", and"] = ", and ",
[", or"] = ", or ",
["by"] = " by ",
["-"] = "–",
["to about"] = " to about ",
["and"] = { off = " and ", on = " and ", exception = true },
["and(-)"] = { input = " and ", output = "–" },
["or"] = { off = " or " , on = " or " , exception = true },
["to"] = { off = " to " , on = " to " , exception = true },
["to(-)"] = { input = " to ", output = "–" },
["+/-"] = { off = " ± ", on = " ± ", adj = " ± ", is_range_change = true },
["by(x)"] = { input = " by ", output = " × ", out_range_x = true },
["x"] = { off = " by ", on = " × ", abbr_range_x = true },
["xx"] = " × ",
["*"] = "×",
["/"] = " / ", -- for a table of high/low temperatures with {{convert|83|/|63|F|disp=br()|abbr=values}}
}
local range_aliases = {
-- ["alternative name for a range"] = "standard range name"
["–"] = "-",
["–"] = "-",
["×"] = "x",
["×"] = "x",
["±"] = "+/-",
["±"] = "+/-",
}
-- Convert accepts range text delimited with whitespace, for example, {{convert|1 to 2|ft}}.
-- In addition, the following "words" are accepted without spaces, for example, {{convert|1-2|ft}}.
-- Words must be in correct order for searching, for example, 'x' after 'xx'.
local range_words = { '-', '–', 'xx', 'x', '*' }
local ranges = {
types = range_types,
aliases = range_aliases,
words = range_words,
}
-- Valid option names.
local en_option_name = {
-- ["local text for option name"] = "en name used in this module"
["$"] = "$",
["abbr"] = "abbr",
["adj"] = "adj",
["altitude_ft"] = "altitude_ft",
["altitude_m"] = "altitude_m",
["comma"] = "comma",
["debug"] = "debug",
["disp"] = "disp",
["frac"] = "frac",
["input"] = "input",
["lang"] = "lang",
["lk"] = "lk",
["order"] = "order",
["qid"] = "qid",
["qual"] = "qual",
["qualifier"] = "qual",
["round"] = "round",
["sigfig"] = "sigfig",
["sing"] = "adj", -- "sing" is an old alias for "adj"
["sortable"] = "sortable",
["sp"] = "sp",
["spell"] = "spell",
["stylein"] = "stylein",
["styleout"] = "styleout",
["tracking"] = "tracking",
}
-- Valid option values.
-- Convention: parms.opt_xxx refers to an option that is set here
-- (not intended to be set by the template which invokes this module).
-- Example: At enwiki, "abbr" includes:
-- ["values"] = "opt_values"
-- As a result, if the template uses abbr=values, Module:Convert sets:
-- parms["opt_values"] = true
-- parms["abbr"] = nil
-- Therefore parms.abbr will be nil, or will have one of the listed values
-- that do not start with "opt_".
-- An option value of form "xxx?" is the same as "xxx" but shows the input as deprecated.
local en_option_value = {
["$"] = 'TEXT', -- TEXT should be a currency symbol that will be used instead of "$"
["abbr"] = {
-- ["local text for option value"] = "en value used in this module"
["def"] = "", -- ignored (some wrapper templates call convert with "abbr=def" to mean "default abbreviation")
["h"] = "on", -- abbr=on + use "h" for hand unit (default)
["hh"] = "opt_hand_hh", -- abbr=on + use "hh" for hand unit
["in"] = "in", -- use symbol for LHS unit
["none"] = "off", -- old name for "off"
["off"] = "off", -- use name for all units
["on"] = "on", -- use symbol for all units
["out"] = "out", -- use symbol for RHS unit (default)
["unit"] = "unit", -- abbr=on but abbreviate units only: e6km → million km (not ×10⁶ km)
["values"] = "opt_values", -- show only input and output numbers, not units
["~"] = "opt_also_symbol", -- show input unit symbol as well as name
},
["adj"] = {
["mid"] = "opt_adjectival, opt_adj_mid", -- adj=on with user-specified text after input unit (between input and output)
["off"] = "", -- ignored (off is the default)
["on"] = "opt_adjectival", -- unit name is singular and hyphenated
["pre"] = "opt_one_preunit", -- user-specified text before input unit
["ri0"] = "opt_ri=0", -- round input with precision = 0
["ri1"] = "opt_ri=1", -- round input with precision = 1
["ri2"] = "opt_ri=2", -- round input with precision = 2
["ri3"] = "opt_ri=3", -- round input with precision = 3
},
["altitude_ft"] = 'INTEGER',
["altitude_m"] = 'INTEGER',
["comma"] = {
["5"] = "opt_comma5", -- only use numsep grouping if 5 or more digits
["gaps"] = "opt_gaps", -- use gaps, not numsep, to separate groups of digits
["gaps3"] = "opt_gaps, opt_gaps3", -- group only in threes rather than default of no gap before a single digit after decimal mark
["off"] = "opt_nocomma", -- no numsep in input or output numbers
},
["debug"] = {
["yes"] = "opt_sortable_debug", -- make the normally hidden sort key visible
},
["disp"] = {
["5"] = "opt_round=5?", -- round output value to nearest 5
["b"] = "b", -- join: '(...)'
["(or)"] = "(or)", -- join: '(...)' with 'or' between outputs in a combination
["br"] = "br", -- join: '<br />'
["br()"] = "br()", -- join: '<br />(...)'
["comma"] = "comma", -- join: ','
["flip"] = "opt_flip", -- reverse order of input/output
["number"] = "opt_output_number_only", -- display output value (not input, and not output symbol/name)
["or"] = "or", -- join: 'or'
["out"] = "opt_output_only",
["output number only"] = "opt_output_number_only",
["output only"] = "opt_output_only",
["preunit"] = "opt_two_preunits", -- user-specified text before input and output units
["semicolon"] = "semicolon", -- join: ';'
["sqbr"] = "sqbr", -- join: '[...]'
["table"] = "opt_table", -- output is suitable for a table cell with align="right"
["tablecen"] = "opt_tablecen", -- output is suitable for a table cell with align="center"
["unit"] = "opt_input_unit_only", -- display input symbol/name (not output, and not input value)
["unit or text"] = "opt_input_unit_only, opt_ignore_error", -- display input symbol/name, or given unit code if not known
["unit2"] = "opt_output_unit_only",
["x"] = "x", -- join: <first>...<second> (user-specified text)
},
["frac"] = 'INTEGER',
["input"] = 'TEXT', -- TEXT should be value><space><unitcode> or <wikidata-property-id>
["lang"] = { -- language for output digits (both en and local digits are always accepted for input)
["en"] = "opt_lang_en", -- use en digits for numbers, regardless of local language
["local"] = "opt_lang_local", -- use local digits for numbers (default, although config can change default to en)
},
["lk"] = {
["in"] = "in", -- link LHS unit name or symbol
["off"] = "off", -- do not link: same as default except for hand unit
["on"] = "on", -- link all unit names or symbols (but not twice for the same unit)
["out"] = "out", -- link RHS unit name or symbol
},
["order"] = {
["flip"] = "opt_flip", -- reverse order of input/output
["out"] = "opt_order_out", -- do not show input; instead, use order in output combination, with the first output shown as the input
},
["qid"] = 'TEXT', -- TEXT should be a Wikidata Q item identifier
["qual"] = 'TEXT', -- TEXT should be a Wikidata Q item identifier
["round"] = {
["0.5"] = "opt_round=0.5", -- round output value to nearest 0.5
["5"] = "opt_round=5", -- round output value to nearest 5
["10"] = "opt_round=10", -- round output value to nearest 10 (same as but clearer than "|-1")
["25"] = "opt_round=25", -- round output value to nearest 25
["50"] = "opt_round=50", -- round output value to nearest 50
["each"] = "opt_round_each", -- using default precision in a range, round each output separately (default uses highest precision of each item in range)
},
["sigfig"] = 'INTEGER',
["sortable"] = {
["off"] = "", -- ignored (off is the default)
["on"] = "opt_sortable_on", -- output sort key for use in a sortable table, based on value from converting to a standard base unit
["debug"] = "opt_sortable_on, opt_sortable_debug", -- |sortable=debug is the same as |sortable=on|debug=yes
},
["sp"] = {
["us"] = "opt_sp_us", -- use U.S. spelling (like "meter" instead of default "metre")
},
["spell"] = { -- only English spelling is supported; not scientific notation; only some fractions
["in"] = "opt_spell_in", -- spell input value in words
["In"] = "opt_spell_in, opt_spell_upper", -- spell input value in words with first letter uppercase
["on"] = "opt_spell_in, opt_spell_out", -- spell input and output values in words
["On"] = "opt_spell_in, opt_spell_out, opt_spell_upper", -- same, with first letter of first word in result uppercase
["us"] = "opt_sp_us", -- use U.S. spelling; same as sp=us so spell=us also works
},
["stylein"] = 'TEXT',
["styleout"] = 'TEXT',
["tracking"] = 'TEXT',
}
local titles = {
["frac"] = "Fraction/styles.css",
["sfrac"] = "Sfrac/styles.css",
}
return {
SIprefixes = SIprefixes,
all_categories = all_categories,
all_messages = all_messages,
currency = { ['$'] = true, ['£'] = true, ['€'] = true, ['₱'] = true, ['₽'] = true, ['¥'] = true },
customary_units = customary_units,
disp_joins = disp_joins,
en_option_name = en_option_name,
en_option_value = en_option_value,
eng_scales = eng_scales,
ranges = ranges,
titles = titles,
}
ff98cf24da87736f3469f82401084ca608335d55
Template:Documentation subpage
10
55
113
2023-04-29T17:27:17Z
Template>Paine Ellsworth
0
m
wikitext
text/x-wiki
<includeonly><!--
-->{{#ifeq:{{lc:{{SUBPAGENAME}}}} |{{{override|doc}}}
| <!--(this template has been transcluded on a /doc or /{{{override}}} page)-->
</includeonly><!--
-->{{#ifeq:{{{doc-notice|show}}} |show
| {{Mbox
| type = notice
| style = margin-bottom:1.0em;
| image = [[File:Edit-copy green.svg|40px|alt=|link=]]
| text =
{{strong|This is a [[Wikipedia:Template documentation|documentation]] [[Wikipedia:Subpages|subpage]]}} for {{terminate sentence|{{{1|[[:{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}}}}<br />It may contain usage information, [[Wikipedia:Categorization|categories]] and other content that is not part of the original {{#if:{{{text2|}}} |{{{text2}}} |{{#if:{{{text1|}}} |{{{text1}}} |{{#ifeq:{{SUBJECTSPACE}} |{{ns:User}} |{{lc:{{SUBJECTSPACE}}}} template page |{{#if:{{SUBJECTSPACE}} |{{lc:{{SUBJECTSPACE}}}} page|article}}}}}}}}.
}}
}}<!--
-->{{DEFAULTSORT:{{{defaultsort|{{PAGENAME}}}}}}}<!--
-->{{#if:{{{inhibit|}}} |<!--(don't categorize)-->
| <includeonly><!--
-->{{#ifexist:{{NAMESPACE}}:{{BASEPAGENAME}}
| [[Category:{{#switch:{{SUBJECTSPACE}} |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
| [[Category:Documentation subpages without corresponding pages]]
}}<!--
--></includeonly>
}}<!--
(completing initial #ifeq: at start of template:)
--><includeonly>
| <!--(this template has not been transcluded on a /doc or /{{{override}}} page)-->
}}<!--
--></includeonly><noinclude>{{Documentation}}</noinclude>
41ca90af0945442788a2dbd08c8c54a61a23c057
Module:Protection banner/config
828
41
85
2023-05-08T11:41:01Z
Template>Fayenatic london
0
Update categories from "fully-protected" to "fully protected", removing hyphen, per valid request at [[WP:CFDS]]
Scribunto
text/plain
-- This module provides configuration data for [[Module:Protection banner]].
return {
--------------------------------------------------------------------------------
--
-- BANNER DATA
--
--------------------------------------------------------------------------------
--[[
-- Banner data consists of six fields:
-- * text - the main protection text that appears at the top of protection
-- banners.
-- * explanation - the text that appears below the main protection text, used
-- to explain the details of the protection.
-- * tooltip - the tooltip text you see when you move the mouse over a small
-- padlock icon.
-- * link - the page that the small padlock icon links to.
-- * alt - the alt text for the small padlock icon. This is also used as tooltip
-- text for the large protection banners.
-- * image - the padlock image used in both protection banners and small padlock
-- icons.
--
-- The module checks in three separate tables to find a value for each field.
-- First it checks the banners table, which has values specific to the reason
-- for the page being protected. Then the module checks the defaultBanners
-- table, which has values specific to each protection level. Finally, the
-- module checks the masterBanner table, which holds data for protection
-- templates to use if no data has been found in the previous two tables.
--
-- The values in the banner data can take parameters. These are specified
-- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name
-- enclosed in curly braces).
--
-- Available parameters:
--
-- ${CURRENTVERSION} - a link to the page history or the move log, with the
-- display message "current-version-edit-display" or
-- "current-version-move-display".
--
-- ${EDITREQUEST} - a link to create an edit request for the current page.
--
-- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes
-- on the talk page; you may submit a request to ask an administrator to make
-- an edit if it is minor or supported by consensus."
--
-- ${IMAGELINK} - a link to set the image to, depending on the protection
-- action and protection level.
--
-- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry
-- is set. E.g. "Editing of this page by new or unregistered users is currently
-- disabled until dd Month YYYY."
--
-- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation
-- so that it can be used in run-on sentences.
--
-- ${PAGETYPE} - the type of the page, e.g. "article" or "template".
-- Defined in the cfg.pagetypes table.
--
-- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g.
-- "Editing of this page by new or unregistered users is currently disabled"
--
-- ${PROTECTIONDATE} - the protection date, if it has been supplied to the
-- template.
--
-- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or
-- "semi-protected".
--
-- ${PROTECTIONLOG} - a link to the protection log or the pending changes log,
-- depending on the protection action.
--
-- ${TALKPAGE} - a link to the talk page. If a section is specified, links
-- straight to that talk page section.
--
-- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to
-- create a blurb like "This template is semi-protected", or "This article is
-- move-protected until DD Month YYYY".
--
-- ${VANDAL} - links for the specified username (or the root page name)
-- using Module:Vandal-m.
--
-- Functions
--
-- For advanced users, it is possible to use Lua functions instead of strings
-- in the banner config tables. Using functions gives flexibility that is not
-- possible just by using parameters. Functions take two arguments, the
-- protection object and the template arguments, and they must output a string.
--
-- For example:
--
-- text = function (protectionObj, args)
-- if protectionObj.level == 'autoconfirmed' then
-- return 'foo'
-- else
-- return 'bar'
-- end
-- end
--
-- Some protection object properties and methods that may be useful:
-- protectionObj.action - the protection action
-- protectionObj.level - the protection level
-- protectionObj.reason - the protection reason
-- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set
-- to indefinite, and the protection time in unix time if temporary.
-- protectionObj.protectionDate - the protection date in unix time, or nil if
-- unspecified.
-- protectionObj.bannerConfig - the banner config found by the module. Beware
-- of editing the config field used by the function, as it could create an
-- infinite loop.
-- protectionObj:isProtected - returns a boolean showing whether the page is
-- protected.
-- protectionObj:isTemporary - returns a boolean showing whether the expiry is
-- temporary.
-- protectionObj:isIncorrect - returns a boolean showing whether the protection
-- template is incorrect.
--]]
-- The master banner data, used if no values have been found in banners or
-- defaultBanners.
masterBanner = {
text = '${INTROBLURB}',
explanation = '${EXPLANATIONBLURB}',
tooltip = '${TOOLTIPBLURB}',
link = '${IMAGELINK}',
alt = 'Page ${PROTECTIONLEVEL}'
},
-- The default banner data. This holds banner data for different protection
-- levels.
-- *required* - this table needs edit, move, autoreview and upload subtables.
defaultBanners = {
edit = {},
move = {},
autoreview = {
default = {
alt = 'Page protected with pending changes',
tooltip = 'All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users',
image = 'Pending-protection-shackle.svg'
}
},
upload = {}
},
-- The banner data. This holds banner data for different protection reasons.
-- In fact, the reasons specified in this table control which reasons are
-- valid inputs to the first positional parameter.
--
-- There is also a non-standard "description" field that can be used for items
-- in this table. This is a description of the protection reason for use in the
-- module documentation.
--
-- *required* - this table needs edit, move, autoreview and upload subtables.
banners = {
edit = {
blp = {
description = 'For pages protected to promote compliance with the'
.. ' [[Wikipedia:Biographies of living persons'
.. '|biographies of living persons]] policy',
text = '${INTROFRAGMENT} to promote compliance with'
.. ' [[Wikipedia:Biographies of living persons'
.. "|Wikipedia's policy on the biographies"
.. ' of living people]].',
tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on'
.. ' biographies of living persons',
},
dmca = {
description = 'For pages protected by the Wikimedia Foundation'
.. ' due to [[Digital Millennium Copyright Act]] takedown requests',
explanation = function (protectionObj, args)
local ret = 'Pursuant to a rights owner notice under the Digital'
.. ' Millennium Copyright Act (DMCA) regarding some content'
.. ' in this article, the Wikimedia Foundation acted under'
.. ' applicable law and took down and restricted the content'
.. ' in question.'
if args.notice then
ret = ret .. ' A copy of the received notice can be found here: '
.. args.notice .. '.'
end
ret = ret .. ' For more information, including websites discussing'
.. ' how to file a counter-notice, please see'
.. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}."
.. "'''Do not remove this template from the article until the"
.. " restrictions are withdrawn'''."
return ret
end,
image = 'Office-protection-shackle.svg',
},
dispute = {
description = 'For pages protected due to editing disputes',
text = function (protectionObj, args)
-- Find the value of "disputes".
local display = 'disputes'
local disputes
if args.section then
disputes = string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[protectionObj.title.namespace].talk.name,
protectionObj.title.text,
args.section,
display
)
else
disputes = display
end
-- Make the blurb, depending on the expiry.
local msg
if type(protectionObj.expiry) == 'number' then
msg = '${INTROFRAGMENT} or until editing %s have been resolved.'
else
msg = '${INTROFRAGMENT} until editing %s have been resolved.'
end
return string.format(msg, disputes)
end,
explanation = "This protection is '''not''' an endorsement of the"
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',
tooltip = '${TOOLTIPFRAGMENT} due to editing disputes',
},
ecp = {
description = 'For articles in topic areas authorized by'
.. ' [[Wikipedia:Arbitration Committee|ArbCom]] or'
.. ' meets the criteria for community use',
tooltip = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',
alt = 'Extended-protected ${PAGETYPE}',
},
mainpage = {
description = 'For pages protected for being displayed on the [[Main Page]]',
text = 'This file is currently'
.. ' [[Wikipedia:This page is protected|protected]] from'
.. ' editing because it is currently or will soon be displayed'
.. ' on the [[Main Page]].',
explanation = 'Images on the Main Page are protected due to their high'
.. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.'
.. '<br /><span style="font-size:90%;">'
.. "'''Administrators:''' Once this image is definitely off the Main Page,"
.. ' please unprotect this file, or reduce to semi-protection,'
.. ' as appropriate.</span>',
},
office = {
description = 'For pages protected by the Wikimedia Foundation',
text = function (protectionObj, args)
local ret = 'This ${PAGETYPE} is currently under the'
.. ' scrutiny of the'
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'
.. ' and is protected.'
if protectionObj.protectionDate then
ret = ret .. ' It has been protected since ${PROTECTIONDATE}.'
end
return ret
end,
explanation = "If you can edit this page, please discuss all changes and"
.. " additions on the ${TALKPAGE} first. '''Do not remove protection from this"
.. " page unless you are authorized by the Wikimedia Foundation to do"
.. " so.'''",
image = 'Office-protection-shackle.svg',
},
reset = {
description = 'For pages protected by the Wikimedia Foundation and'
.. ' "reset" to a bare-bones version',
text = 'This ${PAGETYPE} is currently under the'
.. ' scrutiny of the'
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'
.. ' and is protected.',
explanation = function (protectionObj, args)
local ret = ''
if protectionObj.protectionDate then
ret = ret .. 'On ${PROTECTIONDATE} this ${PAGETYPE} was'
else
ret = ret .. 'This ${PAGETYPE} has been'
end
ret = ret .. ' reduced to a'
.. ' simplified, "bare bones" version so that it may be completely'
.. ' rewritten to ensure it meets the policies of'
.. ' [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].'
.. ' Standard Wikipedia policies will apply to its rewriting—which'
.. ' will eventually be open to all editors—and will be strictly'
.. ' enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while'
.. ' it is being rebuilt.\n\n'
.. 'Any insertion of material directly from'
.. ' pre-protection revisions of the ${PAGETYPE} will be removed, as'
.. ' will any material added to the ${PAGETYPE} that is not properly'
.. ' sourced. The associated talk page(s) were also cleared on the'
.. " same date.\n\n"
.. "If you can edit this page, please discuss all changes and"
.. " additions on the ${TALKPAGE} first. '''Do not override"
.. " this action, and do not remove protection from this page,"
.. " unless you are authorized by the Wikimedia Foundation"
.. " to do so. No editor may remove this notice.'''"
return ret
end,
image = 'Office-protection-shackle.svg',
},
sock = {
description = 'For pages protected due to'
.. ' [[Wikipedia:Sock puppetry|sock puppetry]]',
text = '${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of'
.. ' [[Wikipedia:Blocking policy|blocked]] or'
.. ' [[Wikipedia:Banning policy|banned users]]'
.. ' from editing it.',
tooltip = '${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from'
.. ' editing it',
},
template = {
description = 'For [[Wikipedia:High-risk templates|high-risk]]'
.. ' templates and Lua modules',
text = 'This is a permanently [[Help:Protection|protected]] ${PAGETYPE},'
.. ' as it is [[Wikipedia:High-risk templates|high-risk]].',
explanation = 'Please discuss any changes on the ${TALKPAGE}; you may'
.. ' ${EDITREQUEST} to ask an'
.. ' [[Wikipedia:Administrators|administrator]] or'
.. ' [[Wikipedia:Template editor|template editor]] to make an edit if'
.. ' it is [[Help:Minor edit#When to mark an edit as a minor edit'
.. '|uncontroversial]] or supported by'
.. ' [[Wikipedia:Consensus|consensus]]. You can also'
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'
.. ' unprotected.',
tooltip = 'This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}'
.. ' to prevent vandalism',
alt = 'Permanently protected ${PAGETYPE}',
},
usertalk = {
description = 'For pages protected against disruptive edits by a'
.. ' particular user',
text = '${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,'
.. ' such as abusing the'
.. ' {{[[Template:unblock|unblock]]}} template.',
explanation = 'If you cannot edit this user talk page and you need to'
.. ' make a change or leave a message, you can'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for edits to a protected page'
.. '|request an edit]],'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for reduction in protection level'
.. '|request unprotection]],'
.. ' [[Special:Userlogin|log in]],'
.. ' or [[Special:UserLogin/signup|create an account]].',
},
vandalism = {
description = 'For pages protected against'
.. ' [[Wikipedia:Vandalism|vandalism]]',
text = '${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].',
explanation = function (protectionObj, args)
local ret = ''
if protectionObj.level == 'sysop' then
ret = ret .. "This protection is '''not''' an endorsement of the"
.. ' ${CURRENTVERSION}. '
end
return ret .. '${EXPLANATIONBLURB}'
end,
tooltip = '${TOOLTIPFRAGMENT} due to vandalism',
}
},
move = {
dispute = {
description = 'For pages protected against page moves due to'
.. ' disputes over the page title',
explanation = "This protection is '''not''' an endorsement of the"
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',
image = 'Move-protection-shackle.svg'
},
vandalism = {
description = 'For pages protected against'
.. ' [[Wikipedia:Vandalism#Page-move vandalism'
.. ' |page-move vandalism]]'
}
},
autoreview = {},
upload = {}
},
--------------------------------------------------------------------------------
--
-- GENERAL DATA TABLES
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Protection blurbs
--------------------------------------------------------------------------------
-- This table produces the protection blurbs available with the
-- ${PROTECTIONBLURB} parameter. It is sorted by protection action and
-- protection level, and is checked by the module in the following order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
-- 3. "edit" protection action, default protection level
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, autoreview and upload subtables.
protectionBlurbs = {
edit = {
default = 'This ${PAGETYPE} is currently [[Help:Protection|'
.. 'protected]] from editing',
autoconfirmed = 'Editing of this ${PAGETYPE} by [[Wikipedia:User access'
.. ' levels#New users|new]] or [[Wikipedia:User access levels#Unregistered'
.. ' users|unregistered]] users is currently [[Help:Protection|disabled]]',
extendedconfirmed = 'This ${PAGETYPE} is currently under extended confirmed protection',
},
move = {
default = 'This ${PAGETYPE} is currently [[Help:Protection|protected]]'
.. ' from [[Help:Moving a page|page moves]]'
},
autoreview = {
default = 'All edits made to this ${PAGETYPE} by'
.. ' [[Wikipedia:User access levels#New users|new]] or'
.. ' [[Wikipedia:User access levels#Unregistered users|unregistered]]'
.. ' users are currently'
.. ' [[Wikipedia:Pending changes|subject to review]]'
},
upload = {
default = 'Uploading new versions of this ${PAGETYPE} is currently disabled'
}
},
--------------------------------------------------------------------------------
-- Explanation blurbs
--------------------------------------------------------------------------------
-- This table produces the explanation blurbs available with the
-- ${EXPLANATIONBLURB} parameter. It is sorted by protection action,
-- protection level, and whether the page is a talk page or not. If the page is
-- a talk page it will have a talk key of "talk"; otherwise it will have a talk
-- key of "subject". The table is checked in the following order:
-- 1. page's protection action, page's protection level, page's talk key
-- 2. page's protection action, page's protection level, default talk key
-- 3. page's protection action, default protection level, page's talk key
-- 4. page's protection action, default protection level, default talk key
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, autoreview and upload subtables.
explanationBlurbs = {
edit = {
autoconfirmed = {
subject = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'
.. ' ${EDITREQUEST}, discuss changes on the ${TALKPAGE},'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for reduction in protection level'
.. '|request unprotection]], [[Special:Userlogin|log in]], or'
.. ' [[Special:UserLogin/signup|create an account]].',
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for reduction in protection level'
.. '|request unprotection]], [[Special:Userlogin|log in]], or'
.. ' [[Special:UserLogin/signup|create an account]].',
},
extendedconfirmed = {
default = 'Extended confirmed protection prevents edits from all unregistered editors'
.. ' and registered users with fewer than 30 days tenure and 500 edits.'
.. ' The [[Wikipedia:Protection policy#extended|policy on community use]]'
.. ' specifies that extended confirmed protection can be applied to combat'
.. ' disruption, if semi-protection has proven to be ineffective.'
.. ' Extended confirmed protection may also be applied to enforce'
.. ' [[Wikipedia:Arbitration Committee|arbitration sanctions]].'
.. ' Please discuss any changes on the ${TALKPAGE}; you may'
.. ' ${EDITREQUEST} to ask for uncontroversial changes supported by'
.. ' [[Wikipedia:Consensus|consensus]].'
},
default = {
subject = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' Please discuss any changes on the ${TALKPAGE}; you'
.. ' may ${EDITREQUEST} to ask an'
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'
.. '|consensus]]. You may also [[Wikipedia:Requests for'
.. ' page protection#Current requests for reduction in protection level'
.. '|request]] that this page be unprotected.',
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' You may [[Wikipedia:Requests for page'
.. ' protection#Current requests for edits to a protected page|request an'
.. ' edit]] to this page, or [[Wikipedia:Requests for'
.. ' page protection#Current requests for reduction in protection level'
.. '|ask]] for it to be unprotected.'
}
},
move = {
default = {
subject = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' The page may still be edited but cannot be moved'
.. ' until unprotected. Please discuss any suggested moves on the'
.. ' ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also'
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'
.. ' unprotected.',
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' The page may still be edited but cannot be moved'
.. ' until unprotected. Please discuss any suggested moves at'
.. ' [[Wikipedia:Requested moves]]. You can also'
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'
.. ' unprotected.'
}
},
autoreview = {
default = {
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' Edits to this ${PAGETYPE} by new and unregistered users'
.. ' will not be visible to readers until they are accepted by'
.. ' a reviewer. To avoid the need for your edits to be'
.. ' reviewed, you may'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for reduction in protection level'
.. '|request unprotection]], [[Special:Userlogin|log in]], or'
.. ' [[Special:UserLogin/signup|create an account]].'
},
},
upload = {
default = {
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' The page may still be edited but new versions of the file'
.. ' cannot be uploaded until it is unprotected. You can'
.. ' request that a new version be uploaded by using a'
.. ' [[Wikipedia:Edit requests|protected edit request]], or you'
.. ' can [[Wikipedia:Requests for page protection|request]]'
.. ' that the file be unprotected.'
}
}
},
--------------------------------------------------------------------------------
-- Protection levels
--------------------------------------------------------------------------------
-- This table provides the data for the ${PROTECTIONLEVEL} parameter, which
-- produces a short label for different protection levels. It is sorted by
-- protection action and protection level, and is checked in the following
-- order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
-- 3. "edit" protection action, default protection level
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, autoreview and upload subtables.
protectionLevels = {
edit = {
default = 'protected',
templateeditor = 'template-protected',
extendedconfirmed = 'extended-protected',
autoconfirmed = 'semi-protected',
},
move = {
default = 'move-protected'
},
autoreview = {
},
upload = {
default = 'upload-protected'
}
},
--------------------------------------------------------------------------------
-- Images
--------------------------------------------------------------------------------
-- This table lists different padlock images for each protection action and
-- protection level. It is used if an image is not specified in any of the
-- banner data tables, and if the page does not satisfy the conditions for using
-- the ['image-filename-indef'] image. It is checked in the following order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
images = {
edit = {
default = 'Full-protection-shackle.svg',
templateeditor = 'Template-protection-shackle.svg',
extendedconfirmed = 'Extended-protection-shackle.svg',
autoconfirmed = 'Semi-protection-shackle.svg'
},
move = {
default = 'Move-protection-shackle.svg',
},
autoreview = {
default = 'Pending-protection-shackle.svg'
},
upload = {
default = 'Upload-protection-shackle.svg'
}
},
-- Pages with a reason specified in this table will show the special "indef"
-- padlock, defined in the 'image-filename-indef' message, if no expiry is set.
indefImageReasons = {
template = true
},
--------------------------------------------------------------------------------
-- Image links
--------------------------------------------------------------------------------
-- This table provides the data for the ${IMAGELINK} parameter, which gets
-- the image link for small padlock icons based on the page's protection action
-- and protection level. It is checked in the following order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
-- 3. "edit" protection action, default protection level
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, autoreview and upload subtables.
imageLinks = {
edit = {
default = 'Wikipedia:Protection policy#full',
templateeditor = 'Wikipedia:Protection policy#template',
extendedconfirmed = 'Wikipedia:Protection policy#extended',
autoconfirmed = 'Wikipedia:Protection policy#semi'
},
move = {
default = 'Wikipedia:Protection policy#move'
},
autoreview = {
default = 'Wikipedia:Protection policy#pending'
},
upload = {
default = 'Wikipedia:Protection policy#upload'
}
},
--------------------------------------------------------------------------------
-- Padlock indicator names
--------------------------------------------------------------------------------
-- This table provides the "name" attribute for the <indicator> extension tag
-- with which small padlock icons are generated. All indicator tags on a page
-- are displayed in alphabetical order based on this attribute, and with
-- indicator tags with duplicate names, the last tag on the page wins.
-- The attribute is chosen based on the protection action; table keys must be a
-- protection action name or the string "default".
padlockIndicatorNames = {
autoreview = 'pp-autoreview',
default = 'pp-default'
},
--------------------------------------------------------------------------------
-- Protection categories
--------------------------------------------------------------------------------
--[[
-- The protection categories are stored in the protectionCategories table.
-- Keys to this table are made up of the following strings:
--
-- 1. the expiry date
-- 2. the namespace
-- 3. the protection reason (e.g. "dispute" or "vandalism")
-- 4. the protection level (e.g. "sysop" or "autoconfirmed")
-- 5. the action (e.g. "edit" or "move")
--
-- When the module looks up a category in the table, first it will will check to
-- see a key exists that corresponds to all five parameters. For example, a
-- user page semi-protected from vandalism for two weeks would have the key
-- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module
-- changes the first part of the key to "all" and checks the table again. It
-- keeps checking increasingly generic key combinations until it finds the
-- field, or until it reaches the key "all-all-all-all-all".
--
-- The module uses a binary matrix to determine the order in which to search.
-- This is best demonstrated by a table. In this table, the "0" values
-- represent "all", and the "1" values represent the original data (e.g.
-- "indef" or "file" or "vandalism").
--
-- expiry namespace reason level action
-- order
-- 1 1 1 1 1 1
-- 2 0 1 1 1 1
-- 3 1 0 1 1 1
-- 4 0 0 1 1 1
-- 5 1 1 0 1 1
-- 6 0 1 0 1 1
-- 7 1 0 0 1 1
-- 8 0 0 0 1 1
-- 9 1 1 1 0 1
-- 10 0 1 1 0 1
-- 11 1 0 1 0 1
-- 12 0 0 1 0 1
-- 13 1 1 0 0 1
-- 14 0 1 0 0 1
-- 15 1 0 0 0 1
-- 16 0 0 0 0 1
-- 17 1 1 1 1 0
-- 18 0 1 1 1 0
-- 19 1 0 1 1 0
-- 20 0 0 1 1 0
-- 21 1 1 0 1 0
-- 22 0 1 0 1 0
-- 23 1 0 0 1 0
-- 24 0 0 0 1 0
-- 25 1 1 1 0 0
-- 26 0 1 1 0 0
-- 27 1 0 1 0 0
-- 28 0 0 1 0 0
-- 29 1 1 0 0 0
-- 30 0 1 0 0 0
-- 31 1 0 0 0 0
-- 32 0 0 0 0 0
--
-- In this scheme the action has the highest priority, as it is the last
-- to change, and the expiry has the least priority, as it changes the most.
-- The priorities of the expiry, the protection level and the action are
-- fixed, but the priorities of the reason and the namespace can be swapped
-- through the use of the cfg.bannerDataNamespaceHasPriority table.
--]]
-- If the reason specified to the template is listed in this table,
-- namespace data will take priority over reason data in the protectionCategories
-- table.
reasonsWithNamespacePriority = {
vandalism = true,
},
-- The string to use as a namespace key for the protectionCategories table for each
-- namespace number.
categoryNamespaceKeys = {
[ 2] = 'user',
[ 3] = 'user',
[ 4] = 'project',
[ 6] = 'file',
[ 8] = 'mediawiki',
[ 10] = 'template',
[ 12] = 'project',
[ 14] = 'category',
[100] = 'portal',
[828] = 'module',
},
protectionCategories = {
['all|all|all|all|all'] = 'Wikipedia fully protected pages',
['all|all|office|all|all'] = 'Wikipedia Office-protected pages',
['all|all|reset|all|all'] = 'Wikipedia Office-protected pages',
['all|all|dmca|all|all'] = 'Wikipedia Office-protected pages',
['all|all|mainpage|all|all'] = 'Wikipedia fully protected main page files',
['all|all|all|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',
['all|all|ecp|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',
['all|template|all|all|edit'] = 'Wikipedia fully protected templates',
['all|all|all|autoconfirmed|edit'] = 'Wikipedia semi-protected pages',
['indef|all|all|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected pages',
['all|all|blp|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected biographies of living people',
['temp|all|blp|autoconfirmed|edit'] = 'Wikipedia temporarily semi-protected biographies of living people',
['all|all|dispute|autoconfirmed|edit'] = 'Wikipedia pages semi-protected due to dispute',
['all|all|sock|autoconfirmed|edit'] = 'Wikipedia pages semi-protected from banned users',
['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism',
['all|category|all|autoconfirmed|edit'] = 'Wikipedia semi-protected categories',
['all|file|all|autoconfirmed|edit'] = 'Wikipedia semi-protected files',
['all|portal|all|autoconfirmed|edit'] = 'Wikipedia semi-protected portals',
['all|project|all|autoconfirmed|edit'] = 'Wikipedia semi-protected project pages',
['all|talk|all|autoconfirmed|edit'] = 'Wikipedia semi-protected talk pages',
['all|template|all|autoconfirmed|edit'] = 'Wikipedia semi-protected templates',
['all|user|all|autoconfirmed|edit'] = 'Wikipedia semi-protected user and user talk pages',
['all|all|all|templateeditor|edit'] = 'Wikipedia template-protected pages other than templates and modules',
['all|template|all|templateeditor|edit'] = 'Wikipedia template-protected templates',
['all|template|all|templateeditor|move'] = 'Wikipedia template-protected templates', -- move-protected templates
['all|all|blp|sysop|edit'] = 'Wikipedia indefinitely protected biographies of living people',
['temp|all|blp|sysop|edit'] = 'Wikipedia temporarily protected biographies of living people',
['all|all|dispute|sysop|edit'] = 'Wikipedia pages protected due to dispute',
['all|all|sock|sysop|edit'] = 'Wikipedia pages protected from banned users',
['all|all|vandalism|sysop|edit'] = 'Wikipedia pages protected against vandalism',
['all|category|all|sysop|edit'] = 'Wikipedia fully protected categories',
['all|file|all|sysop|edit'] = 'Wikipedia fully protected files',
['all|project|all|sysop|edit'] = 'Wikipedia fully protected project pages',
['all|talk|all|sysop|edit'] = 'Wikipedia fully protected talk pages',
['all|template|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected templates',
['all|template|all|sysop|edit'] = 'Wikipedia fully protected templates',
['all|user|all|sysop|edit'] = 'Wikipedia fully protected user and user talk pages',
['all|module|all|all|edit'] = 'Wikipedia fully protected modules',
['all|module|all|templateeditor|edit'] = 'Wikipedia template-protected modules',
['all|module|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected modules',
['all|module|all|autoconfirmed|edit'] = 'Wikipedia semi-protected modules',
['all|all|all|sysop|move'] = 'Wikipedia move-protected pages',
['indef|all|all|sysop|move'] = 'Wikipedia indefinitely move-protected pages',
['all|all|dispute|sysop|move'] = 'Wikipedia pages move-protected due to dispute',
['all|all|vandalism|sysop|move'] = 'Wikipedia pages move-protected due to vandalism',
['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals',
['all|project|all|sysop|move'] = 'Wikipedia move-protected project pages',
['all|talk|all|sysop|move'] = 'Wikipedia move-protected talk pages',
['all|template|all|sysop|move'] = 'Wikipedia move-protected templates',
['all|user|all|sysop|move'] = 'Wikipedia move-protected user and user talk pages',
['all|all|all|autoconfirmed|autoreview'] = 'Wikipedia pending changes protected pages',
['all|file|all|all|upload'] = 'Wikipedia upload-protected files',
},
--------------------------------------------------------------------------------
-- Expiry category config
--------------------------------------------------------------------------------
-- This table configures the expiry category behaviour for each protection
-- action.
-- * If set to true, setting that action will always categorise the page if
-- an expiry parameter is not set.
-- * If set to false, setting that action will never categorise the page.
-- * If set to nil, the module will categorise the page if:
-- 1) an expiry parameter is not set, and
-- 2) a reason is provided, and
-- 3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck
-- table.
expiryCheckActions = {
edit = nil,
move = false,
autoreview = true,
upload = false
},
reasonsWithoutExpiryCheck = {
blp = true,
template = true,
},
--------------------------------------------------------------------------------
-- Pagetypes
--------------------------------------------------------------------------------
-- This table produces the page types available with the ${PAGETYPE} parameter.
-- Keys are namespace numbers, or the string "default" for the default value.
pagetypes = {
[0] = 'article',
[6] = 'file',
[10] = 'template',
[14] = 'category',
[828] = 'module',
default = 'page'
},
--------------------------------------------------------------------------------
-- Strings marking indefinite protection
--------------------------------------------------------------------------------
-- This table contains values passed to the expiry parameter that mean the page
-- is protected indefinitely.
indefStrings = {
['indef'] = true,
['indefinite'] = true,
['indefinitely'] = true,
['infinite'] = true,
},
--------------------------------------------------------------------------------
-- Group hierarchy
--------------------------------------------------------------------------------
-- This table maps each group to all groups that have a superset of the original
-- group's page editing permissions.
hierarchy = {
sysop = {},
reviewer = {'sysop'},
filemover = {'sysop'},
templateeditor = {'sysop'},
extendedconfirmed = {'sysop'},
autoconfirmed = {'reviewer', 'filemover', 'templateeditor', 'extendedconfirmed'},
user = {'autoconfirmed'},
['*'] = {'user'}
},
--------------------------------------------------------------------------------
-- Wrapper templates and their default arguments
--------------------------------------------------------------------------------
-- This table contains wrapper templates used with the module, and their
-- default arguments. Templates specified in this table should contain the
-- following invocation, and no other template content:
--
-- {{#invoke:Protection banner|main}}
--
-- If other content is desired, it can be added between
-- <noinclude>...</noinclude> tags.
--
-- When a user calls one of these wrapper templates, they will use the
-- default arguments automatically. However, users can override any of the
-- arguments.
wrappers = {
['Template:Pp'] = {},
['Template:Pp-extended'] = {'ecp'},
['Template:Pp-blp'] = {'blp'},
-- we don't need Template:Pp-create
['Template:Pp-dispute'] = {'dispute'},
['Template:Pp-main-page'] = {'mainpage'},
['Template:Pp-move'] = {action = 'move', catonly = 'yes'},
['Template:Pp-move-dispute'] = {'dispute', action = 'move', catonly = 'yes'},
-- we don't need Template:Pp-move-indef
['Template:Pp-move-vandalism'] = {'vandalism', action = 'move', catonly = 'yes'},
['Template:Pp-office'] = {'office'},
['Template:Pp-office-dmca'] = {'dmca'},
['Template:Pp-pc'] = {action = 'autoreview', small = true},
['Template:Pp-pc1'] = {action = 'autoreview', small = true},
['Template:Pp-reset'] = {'reset'},
['Template:Pp-semi-indef'] = {small = true},
['Template:Pp-sock'] = {'sock'},
['Template:Pp-template'] = {'template', small = true},
['Template:Pp-upload'] = {action = 'upload'},
['Template:Pp-usertalk'] = {'usertalk'},
['Template:Pp-vandalism'] = {'vandalism'},
},
--------------------------------------------------------------------------------
--
-- MESSAGES
--
--------------------------------------------------------------------------------
msg = {
--------------------------------------------------------------------------------
-- Intro blurb and intro fragment
--------------------------------------------------------------------------------
-- These messages specify what is produced by the ${INTROBLURB} and
-- ${INTROFRAGMENT} parameters. If the protection is temporary they use the
-- intro-blurb-expiry or intro-fragment-expiry, and if not they use
-- intro-blurb-noexpiry or intro-fragment-noexpiry.
-- It is possible to use banner parameters in these messages.
['intro-blurb-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY}.',
['intro-blurb-noexpiry'] = '${PROTECTIONBLURB}.',
['intro-fragment-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY},',
['intro-fragment-noexpiry'] = '${PROTECTIONBLURB}',
--------------------------------------------------------------------------------
-- Tooltip blurb
--------------------------------------------------------------------------------
-- These messages specify what is produced by the ${TOOLTIPBLURB} parameter.
-- If the protection is temporary the tooltip-blurb-expiry message is used, and
-- if not the tooltip-blurb-noexpiry message is used.
-- It is possible to use banner parameters in these messages.
['tooltip-blurb-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.',
['tooltip-blurb-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}.',
['tooltip-fragment-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},',
['tooltip-fragment-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',
--------------------------------------------------------------------------------
-- Special explanation blurb
--------------------------------------------------------------------------------
-- An explanation blurb for pages that cannot be unprotected, e.g. for pages
-- in the MediaWiki namespace.
-- It is possible to use banner parameters in this message.
['explanation-blurb-nounprotect'] = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' Please discuss any changes on the ${TALKPAGE}; you'
.. ' may ${EDITREQUEST} to ask an'
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'
.. '|consensus]].',
--------------------------------------------------------------------------------
-- Protection log display values
--------------------------------------------------------------------------------
-- These messages determine the display values for the protection log link
-- or the pending changes log link produced by the ${PROTECTIONLOG} parameter.
-- It is possible to use banner parameters in these messages.
['protection-log-display'] = 'protection log',
['pc-log-display'] = 'pending changes log',
--------------------------------------------------------------------------------
-- Current version display values
--------------------------------------------------------------------------------
-- These messages determine the display values for the page history link
-- or the move log link produced by the ${CURRENTVERSION} parameter.
-- It is possible to use banner parameters in these messages.
['current-version-move-display'] = 'current title',
['current-version-edit-display'] = 'current version',
--------------------------------------------------------------------------------
-- Talk page
--------------------------------------------------------------------------------
-- This message determines the display value of the talk page link produced
-- with the ${TALKPAGE} parameter.
-- It is possible to use banner parameters in this message.
['talk-page-link-display'] = 'talk page',
--------------------------------------------------------------------------------
-- Edit requests
--------------------------------------------------------------------------------
-- This message determines the display value of the edit request link produced
-- with the ${EDITREQUEST} parameter.
-- It is possible to use banner parameters in this message.
['edit-request-display'] = 'submit an edit request',
--------------------------------------------------------------------------------
-- Expiry date format
--------------------------------------------------------------------------------
-- This is the format for the blurb expiry date. It should be valid input for
-- the first parameter of the #time parser function.
['expiry-date-format'] = 'F j, Y "at" H:i e',
--------------------------------------------------------------------------------
-- Tracking categories
--------------------------------------------------------------------------------
-- These messages determine which tracking categories the module outputs.
['tracking-category-incorrect'] = 'Wikipedia pages with incorrect protection templates',
['tracking-category-template'] = 'Wikipedia template-protected pages other than templates and modules',
--------------------------------------------------------------------------------
-- Images
--------------------------------------------------------------------------------
-- These are images that are not defined by their protection action and protection level.
['image-filename-indef'] = 'Full-protection-shackle.svg',
['image-filename-default'] = 'Transparent.gif',
--------------------------------------------------------------------------------
-- End messages
--------------------------------------------------------------------------------
}
--------------------------------------------------------------------------------
-- End configuration
--------------------------------------------------------------------------------
}
a20552ae38cb5253a4fa29aa126abc74215a589f
Module:Convert/data
828
89
181
2023-05-10T03:20:18Z
w>Johnuniq
0
update from sandbox per [[Template talk:Convert#Module version 29]]
Scribunto
text/plain
-- Conversion data used by [[Module:Convert]] which uses mw.loadData() for
-- read-only access to this module so that it is loaded only once per page.
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
--
-- These data tables follow:
-- all_units all properties for a unit, including default output
-- default_exceptions exceptions for default output ('kg' and 'g' have different defaults)
-- link_exceptions exceptions for links ('kg' and 'g' have different links)
--
-- These tables are generated by a script which reads the wikitext of a page that
-- documents the required properties of each unit; see [[:en:Module:Convert/doc]].
---------------------------------------------------------------------------
-- Do not change the data in this table because it is created by running --
-- a script that reads the wikitext from a wiki page (see note above). --
---------------------------------------------------------------------------
local all_units = {
["Gy"] = {
_name1 = "gray",
_symbol = "Gy",
utype = "absorbed radiation dose",
scale = 1,
prefixes = 1,
default = "rad",
link = "Gray (unit)",
},
["rad"] = {
_name1 = "rad",
_symbol = "rad",
utype = "absorbed radiation dose",
scale = 0.01,
prefixes = 1,
default = "Gy",
link = "Rad (unit)",
},
["cm/s2"] = {
name1 = "centimetre per second squared",
name1_us = "centimeter per second squared",
name2 = "centimetres per second squared",
name2_us = "centimeters per second squared",
symbol = "cm/s<sup>2</sup>",
utype = "acceleration",
scale = 0.01,
default = "ft/s2",
link = "Gal (unit)",
},
["ft/s2"] = {
name1 = "foot per second squared",
name2 = "feet per second squared",
symbol = "ft/s<sup>2</sup>",
utype = "acceleration",
scale = 0.3048,
default = "m/s2",
},
["g0"] = {
name1 = "standard gravity",
name2 = "standard gravities",
symbol = "''g''<sub>0</sub>",
utype = "acceleration",
scale = 9.80665,
default = "m/s2",
},
["g-force"] = {
name2 = "''g''",
symbol = "''g''",
utype = "acceleration",
scale = 9.80665,
default = "m/s2",
link = "g-force",
},
["km/hs"] = {
name1 = "kilometre per hour per second",
name1_us = "kilometer per hour per second",
name2 = "kilometres per hour per second",
name2_us = "kilometers per hour per second",
symbol = "km/(h⋅s)",
utype = "acceleration",
scale = 0.27777777777777779,
default = "mph/s",
link = "Acceleration",
},
["km/s2"] = {
name1 = "kilometre per second squared",
name1_us = "kilometer per second squared",
name2 = "kilometres per second squared",
name2_us = "kilometers per second squared",
symbol = "km/s<sup>2</sup>",
utype = "acceleration",
scale = 1000,
default = "mph/s",
link = "Acceleration",
},
["m/s2"] = {
name1 = "metre per second squared",
name1_us = "meter per second squared",
name2 = "metres per second squared",
name2_us = "meters per second squared",
symbol = "m/s<sup>2</sup>",
utype = "acceleration",
scale = 1,
default = "ft/s2",
},
["mph/s"] = {
name1 = "mile per hour per second",
name2 = "miles per hour per second",
symbol = "mph/s",
utype = "acceleration",
scale = 0.44704,
default = "km/hs",
link = "Acceleration",
},
["km/h/s"] = {
target = "km/hs",
},
["standard gravity"] = {
target = "g0",
},
["1000sqft"] = {
name1 = "thousand square feet",
name2 = "thousand square feet",
symbol = "1000 sq ft",
utype = "area",
scale = 92.90304,
default = "m2",
link = "Square foot",
},
["a"] = {
_name1 = "are",
_symbol = "a",
utype = "area",
scale = 100,
prefixes = 1,
default = "sqft",
link = "Hectare#Are",
},
["acre"] = {
symbol = "acre",
usename = 1,
utype = "area",
scale = 4046.8564224,
default = "ha",
subdivs = { ["rood"] = { 4, default = "ha" }, ["sqperch"] = { 160, default = "ha" } },
},
["acre-sing"] = {
target = "acre",
},
["arpent"] = {
symbol = "arpent",
usename = 1,
utype = "area",
scale = 3418.89,
default = "ha",
},
["cda"] = {
name1 = "cuerda",
symbol = "cda",
utype = "area",
scale = 3930.395625,
default = "ha acre",
},
["daa"] = {
name1 = "decare",
symbol = "daa",
utype = "area",
scale = 1000,
default = "km2 sqmi",
},
["dunam"] = {
symbol = "dunam",
usename = 1,
utype = "area",
scale = 1000,
default = "km2 sqmi",
},
["dunum"] = {
symbol = "dunum",
usename = 1,
utype = "area",
scale = 1000,
default = "km2 sqmi",
link = "Dunam",
},
["ha"] = {
name1 = "hectare",
symbol = "ha",
utype = "area",
scale = 10000,
default = "acre",
},
["hectare"] = {
name1 = "hectare",
symbol = "ha",
usename = 1,
utype = "area",
scale = 10000,
default = "acre",
},
["Irish acre"] = {
name1 = "Irish acre",
symbol = "Irish acres",
utype = "area",
scale = 6555.2385024,
default = "ha",
link = "Acre (Irish)",
},
["m2"] = {
_name1 = "square metre",
_name1_us= "square meter",
_symbol = "m<sup>2</sup>",
prefix_position= 8,
utype = "area",
scale = 1,
prefixes = 2,
default = "sqft",
link = "Square metre",
},
["pondemaat"] = {
name1 = "pondemaat",
name2 = "pondemaat",
symbol = "pond",
utype = "area",
scale = 3674.363358816,
default = "m2",
link = ":nl:pondemaat",
},
["pyeong"] = {
name2 = "pyeong",
symbol = "pyeong",
usename = 1,
utype = "area",
scale = 3.3057851239669422,
default = "m2",
},
["rai"] = {
name2 = "rai",
symbol = "rai",
utype = "area",
scale = 1600,
default = "m2",
link = "Rai (unit)",
},
["rood"] = {
symbol = "rood",
usename = 1,
utype = "area",
scale = 1011.7141056,
default = "sqft m2",
subdivs = { ["sqperch"] = { 40, default = "m2" } },
link = "Rood (unit)",
},
["sqfoot"] = {
name1 = "square foot",
name2 = "square foot",
symbol = "sq ft",
utype = "area",
scale = 0.09290304,
default = "m2",
},
["sqft"] = {
name1 = "square foot",
name2 = "square feet",
symbol = "sq ft",
utype = "area",
scale = 0.09290304,
default = "m2",
},
["sqin"] = {
name1 = "square inch",
name2 = "square inches",
symbol = "sq in",
utype = "area",
scale = 0.00064516,
default = "cm2",
},
["sqmi"] = {
name1 = "square mile",
symbol = "sq mi",
utype = "area",
scale = 2589988.110336,
default = "km2",
},
["sqnmi"] = {
name1 = "square nautical mile",
symbol = "sq nmi",
utype = "area",
scale = 3429904,
default = "km2 sqmi",
link = "Nautical mile",
},
["sqperch"] = {
name2 = "perches",
symbol = "perch",
usename = 1,
utype = "area",
scale = 25.29285264,
default = "m2",
link = "Rod (unit)#Area and volume",
},
["sqverst"] = {
symbol = "square verst",
usename = 1,
utype = "area",
scale = 1138062.24,
default = "km2 sqmi",
link = "Verst",
},
["sqyd"] = {
name1 = "square yard",
symbol = "sq yd",
utype = "area",
scale = 0.83612736,
default = "m2",
},
["tsubo"] = {
name2 = "tsubo",
symbol = "tsubo",
usename = 1,
utype = "area",
scale = 3.3057851239669422,
default = "m2",
link = "Japanese units of measurement#Area",
},
["acres"] = {
target = "acre",
},
["are"] = {
target = "a",
},
["decare"] = {
target = "daa",
},
["foot2"] = {
target = "sqfoot",
},
["ft2"] = {
target = "sqft",
},
["in2"] = {
target = "sqin",
symbol = "in<sup>2</sup>",
},
["km²"] = {
target = "km2",
},
["mi2"] = {
target = "sqmi",
},
["million acre"] = {
target = "e6acre",
},
["million acres"] = {
target = "e6acre",
},
["million hectares"] = {
target = "e6ha",
},
["m²"] = {
target = "m2",
},
["nmi2"] = {
target = "sqnmi",
},
["pond"] = {
target = "pondemaat",
},
["sq arp"] = {
target = "arpent",
},
["sqkm"] = {
target = "km2",
},
["sqm"] = {
target = "m2",
},
["square verst"] = {
target = "sqverst",
},
["verst2"] = {
target = "sqverst",
},
["yd2"] = {
target = "sqyd",
},
["m2/ha"] = {
name1 = "square metre per hectare",
name1_us = "square meter per hectare",
name2 = "square metres per hectare",
name2_us = "square meters per hectare",
symbol = "m<sup>2</sup>/ha",
utype = "area per unit area",
scale = 0.0001,
default = "sqft/acre",
link = "Basal area",
},
["sqft/acre"] = {
name1 = "square foot per acre",
name2 = "square feet per acre",
symbol = "sq ft/acre",
utype = "area per unit area",
scale = 2.295684113865932e-5,
default = "m2/ha",
link = "Basal area",
},
["cent"] = {
name1 = "cent",
symbol = "¢",
utype = "cent",
scale = 1,
default = "cent",
link = "Cent (currency)",
},
["¢"] = {
target = "cent",
},
["A.h"] = {
name1 = "ampere hour",
symbol = "A⋅h",
utype = "charge",
scale = 3600,
default = "coulomb",
},
["coulomb"] = {
_name1 = "coulomb",
_symbol = "C",
utype = "charge",
scale = 1,
prefixes = 1,
default = "e",
link = "Coulomb",
},
["e"] = {
name1 = "elementary charge",
symbol = "''e''",
utype = "charge",
scale = 1.602176487e-19,
default = "coulomb",
},
["g-mol"] = {
name1 = "gram-mole",
symbol = "g‑mol",
utype = "chemical amount",
scale = 1,
default = "lbmol",
link = "Mole (unit)",
},
["gmol"] = {
name1 = "gram-mole",
symbol = "gmol",
utype = "chemical amount",
scale = 1,
default = "lbmol",
link = "Mole (unit)",
},
["kmol"] = {
name1 = "kilomole",
symbol = "kmol",
utype = "chemical amount",
scale = 1000,
default = "lbmol",
link = "Mole (unit)",
},
["lb-mol"] = {
name1 = "pound-mole",
symbol = "lb‑mol",
utype = "chemical amount",
scale = 453.59237,
default = "mol",
},
["lbmol"] = {
name1 = "pound-mole",
symbol = "lbmol",
utype = "chemical amount",
scale = 453.59237,
default = "mol",
},
["mol"] = {
name1 = "mole",
symbol = "mol",
utype = "chemical amount",
scale = 1,
default = "lbmol",
link = "Mole (unit)",
},
["kgCO2/L"] = {
name1 = "kilogram per litre",
name1_us = "kilogram per liter",
name2 = "kilograms per litre",
name2_us = "kilograms per liter",
symbol = "kg(CO<sub>2</sub>)/L",
utype = "co2 per unit volume",
scale = 1000,
default = "lbCO2/USgal",
link = "Exhaust gas",
},
["lbCO2/USgal"] = {
name1 = "pound per US gallon",
name2 = "pounds per US gallon",
symbol = "lbCO2/US gal",
utype = "co2 per unit volume",
scale = 119.82642731689663,
default = "kgCO2/L",
link = "Exhaust gas",
},
["oz/lb"] = {
per = { "oz", "lb" },
utype = "concentration",
default = "mg/kg",
},
["mg/kg"] = {
per = { "mg", "kg" },
utype = "concentration",
default = "oz/lb",
},
["g/dm3"] = {
name1 = "gram per cubic decimetre",
name1_us = "gram per cubic decimeter",
name2 = "grams per cubic decimetre",
name2_us = "grams per cubic decimeter",
symbol = "g/dm<sup>3</sup>",
utype = "density",
scale = 1,
default = "kg/m3",
link = "Density",
},
["g/L"] = {
name1 = "gram per litre",
name1_us = "gram per liter",
name2 = "grams per litre",
name2_us = "grams per liter",
symbol = "g/L",
utype = "density",
scale = 1,
default = "lb/cuin",
link = "Density",
},
["g/mL"] = {
name1 = "gram per millilitre",
name1_us = "gram per milliliter",
name2 = "grams per millilitre",
name2_us = "grams per milliliter",
symbol = "g/mL",
utype = "density",
scale = 1000,
default = "lb/cuin",
link = "Density",
},
["g/ml"] = {
name1 = "gram per millilitre",
name1_us = "gram per milliliter",
name2 = "grams per millilitre",
name2_us = "grams per milliliter",
symbol = "g/ml",
utype = "density",
scale = 1000,
default = "lb/cuin",
link = "Density",
},
["kg/dm3"] = {
name1 = "kilogram per cubic decimetre",
name1_us = "kilogram per cubic decimeter",
name2 = "kilograms per cubic decimetre",
name2_us = "kilograms per cubic decimeter",
symbol = "kg/dm<sup>3</sup>",
utype = "density",
scale = 1000,
default = "lb/cuft",
link = "Density",
},
["kg/L"] = {
name1 = "kilogram per litre",
name1_us = "kilogram per liter",
name2 = "kilograms per litre",
name2_us = "kilograms per liter",
symbol = "kg/L",
utype = "density",
scale = 1000,
default = "lb/USgal",
link = "Density",
},
["kg/l"] = {
name1 = "kilogram per litre",
name1_us = "kilogram per liter",
name2 = "kilograms per litre",
name2_us = "kilograms per liter",
symbol = "kg/l",
utype = "density",
scale = 1000,
default = "lb/USgal",
link = "Density",
},
["kg/m3"] = {
name1 = "kilogram per cubic metre",
name1_us = "kilogram per cubic meter",
name2 = "kilograms per cubic metre",
name2_us = "kilograms per cubic meter",
symbol = "kg/m<sup>3</sup>",
utype = "density",
scale = 1,
default = "lb/cuyd",
link = "Density",
},
["lb/cuft"] = {
name1 = "pound per cubic foot",
name2 = "pounds per cubic foot",
symbol = "lb/cu ft",
utype = "density",
scale = 16.018463373960142,
default = "g/cm3",
link = "Density",
},
["lb/cuin"] = {
name1 = "pound per cubic inch",
name2 = "pounds per cubic inch",
symbol = "lb/cu in",
utype = "density",
scale = 27679.904710203122,
default = "g/cm3",
link = "Density",
},
["lb/cuyd"] = {
name1 = "pound per cubic yard",
name2 = "pounds per cubic yard",
symbol = "lb/cu yd",
utype = "density",
scale = 0.5932764212577829,
default = "kg/m3",
link = "Density",
},
["lb/impgal"] = {
name1 = "pound per imperial gallon",
name2 = "pounds per imperial gallon",
symbol = "lb/imp gal",
utype = "density",
scale = 99.776372663101697,
default = "kg/L",
link = "Density",
},
["lb/in3"] = {
name1 = "pound per cubic inch",
name2 = "pounds per cubic inch",
symbol = "lb/cu in",
utype = "density",
scale = 27679.904710203122,
default = "g/cm3",
link = "Density",
},
["lb/U.S.gal"] = {
name1 = "pound per U.S. gallon",
name2 = "pounds per U.S. gallon",
symbol = "lb/U.S. gal",
utype = "density",
scale = 119.82642731689663,
default = "kg/L",
link = "Density",
},
["lb/USbu"] = {
name1 = "pound per US bushel",
name2 = "pounds per US bushel",
symbol = "lb/US bu",
utype = "density",
scale = 12.871859780974471,
default = "kg/m3",
link = "Bushel",
},
["lb/USgal"] = {
name1 = "pound per US gallon",
name2 = "pounds per US gallon",
symbol = "lb/US gal",
utype = "density",
scale = 119.82642731689663,
default = "kg/L",
link = "Density",
},
["lbm/cuin"] = {
name1 = "pound mass per cubic inch",
name2 = "pounds mass per cubic inch",
symbol = "lbm/cu in",
utype = "density",
scale = 27679.904710203122,
default = "g/cm3",
link = "Density",
},
["mg/L"] = {
name1 = "milligram per litre",
name1_us = "milligram per liter",
name2 = "milligrams per litre",
name2_us = "milligrams per liter",
symbol = "mg/L",
utype = "density",
scale = 0.001,
default = "lb/cuin",
link = "Density",
},
["oz/cuin"] = {
name1 = "ounce per cubic inch",
name2 = "ounces per cubic inch",
symbol = "oz/cu in",
utype = "density",
scale = 1729.9940443876951,
default = "g/cm3",
link = "Density",
},
["g/cm3"] = {
per = { "g", "cm3" },
utype = "density",
default = "lb/cuin",
},
["g/m3"] = {
per = { "g", "m3" },
utype = "density",
default = "lb/cuyd",
link = "Density",
},
["Mg/m3"] = {
per = { "Mg", "m3" },
utype = "density",
default = "lb/cuft",
},
["mg/l"] = {
per = { "mg", "ll" },
utype = "density",
default = "oz/cuin",
},
["μg/dL"] = {
per = { "μg", "dL" },
utype = "density",
default = "lb/cuin",
},
["μg/l"] = {
per = { "μg", "ll" },
utype = "density",
default = "oz/cuin",
},
["lb/ft3"] = {
target = "lb/cuft",
},
["lb/yd3"] = {
target = "lb/cuyd",
},
["lbm/in3"] = {
target = "lbm/cuin",
},
["mcg/dL"] = {
target = "μg/dL",
},
["oz/in3"] = {
target = "oz/cuin",
},
["ug/dL"] = {
target = "μg/dL",
},
["ug/l"] = {
target = "μg/l",
},
["B.O.T.U."] = {
name1 = "Board of Trade Unit",
symbol = "B.O.T.U.",
utype = "energy",
scale = 3600000,
default = "MJ",
link = "Kilowatt-hour",
},
["bboe"] = {
name1 = "barrel of oil equivalent",
name2 = "barrels of oil equivalent",
symbol = "bboe",
utype = "energy",
scale = 6117863200,
default = "GJ",
},
["BOE"] = {
name1 = "barrel of oil equivalent",
name2 = "barrels of oil equivalent",
symbol = "BOE",
utype = "energy",
scale = 6117863200,
default = "GJ",
},
["BTU"] = {
name1 = "British thermal unit",
symbol = "BTU",
utype = "energy",
scale = 1055.05585262,
default = "kJ",
},
["Btu"] = {
name1 = "British thermal unit",
symbol = "Btu",
utype = "energy",
scale = 1055.05585262,
default = "kJ",
},
["BTU-39F"] = {
name1 = "British thermal unit (39°F)",
name2 = "British thermal units (39°F)",
symbol = "BTU<sub>39°F</sub>",
utype = "energy",
scale = 1059.67,
default = "kJ",
link = "British thermal unit",
},
["Btu-39F"] = {
name1 = "British thermal unit (39°F)",
name2 = "British thermal units (39°F)",
symbol = "Btu<sub>39°F</sub>",
utype = "energy",
scale = 1059.67,
default = "kJ",
link = "British thermal unit",
},
["BTU-59F"] = {
name1 = "British thermal unit (59°F)",
name2 = "British thermal units (59°F)",
symbol = "BTU<sub>59°F</sub>",
utype = "energy",
scale = 1054.804,
default = "kJ",
link = "British thermal unit",
},
["Btu-59F"] = {
name1 = "British thermal unit (59°F)",
name2 = "British thermal units (59°F)",
symbol = "Btu<sub>59°F</sub>",
utype = "energy",
scale = 1054.804,
default = "kJ",
link = "British thermal unit",
},
["BTU-60F"] = {
name1 = "British thermal unit (60°F)",
name2 = "British thermal units (60°F)",
symbol = "BTU<sub>60°F</sub>",
utype = "energy",
scale = 1054.68,
default = "kJ",
link = "British thermal unit",
},
["Btu-60F"] = {
name1 = "British thermal unit (60°F)",
name2 = "British thermal units (60°F)",
symbol = "Btu<sub>60°F</sub>",
utype = "energy",
scale = 1054.68,
default = "kJ",
link = "British thermal unit",
},
["BTU-63F"] = {
name1 = "British thermal unit (63°F)",
name2 = "British thermal units (63°F)",
symbol = "BTU<sub>63°F</sub>",
utype = "energy",
scale = 1054.6,
default = "kJ",
link = "British thermal unit",
},
["Btu-63F"] = {
name1 = "British thermal unit (63°F)",
name2 = "British thermal units (63°F)",
symbol = "Btu<sub>63°F</sub>",
utype = "energy",
scale = 1054.6,
default = "kJ",
link = "British thermal unit",
},
["BTU-ISO"] = {
name1 = "British thermal unit (ISO)",
name2 = "British thermal units (ISO)",
symbol = "BTU<sub>ISO</sub>",
utype = "energy",
scale = 1055.056,
default = "kJ",
link = "British thermal unit",
},
["Btu-ISO"] = {
target = "BTU-ISO",
},
["BTU-IT"] = {
name1 = "British thermal unit (IT)",
name2 = "British thermal units (IT)",
symbol = "BTU<sub>IT</sub>",
utype = "energy",
scale = 1055.05585262,
default = "kJ",
link = "British thermal unit",
},
["Btu-IT"] = {
name1 = "British thermal unit (IT)",
name2 = "British thermal units (IT)",
symbol = "Btu<sub>IT</sub>",
utype = "energy",
scale = 1055.05585262,
default = "kJ",
link = "British thermal unit",
},
["BTU-mean"] = {
name1 = "British thermal unit (mean)",
name2 = "British thermal units (mean)",
symbol = "BTU<sub>mean</sub>",
utype = "energy",
scale = 1055.87,
default = "kJ",
link = "British thermal unit",
},
["Btu-mean"] = {
name1 = "British thermal unit (mean)",
name2 = "British thermal units (mean)",
symbol = "Btu<sub>mean</sub>",
utype = "energy",
scale = 1055.87,
default = "kJ",
link = "British thermal unit",
},
["BTU-th"] = {
name1 = "British thermal unit (thermochemical)",
name2 = "British thermal units (thermochemical)",
symbol = "BTU<sub>th</sub>",
utype = "energy",
scale = 1054.35026444,
default = "kJ",
link = "British thermal unit",
},
["Btu-th"] = {
name1 = "British thermal unit (thermochemical)",
name2 = "British thermal units (thermochemical)",
symbol = "Btu<sub>th</sub>",
utype = "energy",
scale = 1054.35026444,
default = "kJ",
link = "British thermal unit",
},
["Cal"] = {
name1 = "calorie",
symbol = "Cal",
utype = "energy",
scale = 4184,
default = "kJ",
},
["cal"] = {
name1 = "calorie",
symbol = "cal",
utype = "energy",
scale = 4.184,
default = "J",
},
["Cal-15"] = {
name1 = "Calorie (15°C)",
name2 = "Calories (15°C)",
symbol = "Cal<sub>15</sub>",
utype = "energy",
scale = 4185.8,
default = "kJ",
link = "Calorie",
},
["cal-15"] = {
name1 = "calorie (15°C)",
name2 = "calories (15°C)",
symbol = "cal<sub>15</sub>",
utype = "energy",
scale = 4.1858,
default = "J",
link = "Calorie",
},
["Cal-IT"] = {
name1 = "Calorie (International Steam Table)",
name2 = "Calories (International Steam Table)",
symbol = "Cal<sub>IT</sub>",
utype = "energy",
scale = 4186.8,
default = "kJ",
link = "Calorie",
},
["cal-IT"] = {
name1 = "calorie (International Steam Table)",
name2 = "calories (International Steam Table)",
symbol = "cal<sub>IT</sub>",
utype = "energy",
scale = 4.1868,
default = "J",
link = "Calorie",
},
["Cal-th"] = {
name1 = "Calorie (thermochemical)",
name2 = "Calories (thermochemical)",
symbol = "Cal<sub>th</sub>",
utype = "energy",
scale = 4184,
default = "kJ",
link = "Calorie",
},
["cal-th"] = {
name1 = "calorie (thermochemical)",
name2 = "calories (thermochemical)",
symbol = "cal<sub>th</sub>",
utype = "energy",
scale = 4.184,
default = "J",
link = "Calorie",
},
["CHU-IT"] = {
name1 = "Celsius heat unit (International Table)",
name2 = "Celsius heat units (International Table)",
symbol = "CHU<sub>IT</sub>",
utype = "energy",
scale = 1899.100534716,
default = "kJ",
link = "Conversion of units#Energy",
},
["cufootnaturalgas"] = {
name1 = "cubic foot of natural gas",
name2 = "cubic foot of natural gas",
symbol = "cuftnaturalgas",
usename = 1,
utype = "energy",
scale = 1055055.85262,
default = "MJ",
link = "Conversion of units#Energy",
},
["cuftnaturalgas"] = {
name1 = "cubic foot of natural gas",
name2 = "cubic feet of natural gas",
symbol = "cuftnaturalgas",
usename = 1,
utype = "energy",
scale = 1055055.85262,
default = "MJ",
link = "Conversion of units#Energy",
},
["Eh"] = {
name1 = "Hartree",
symbol = "''E''<sub>h</sub>",
utype = "energy",
scale = 4.35974417e-18,
default = "eV",
},
["erg"] = {
symbol = "erg",
utype = "energy",
scale = 0.0000001,
default = "μJ",
},
["eV"] = {
name1 = "electronvolt",
symbol = "eV",
utype = "energy",
scale = 1.602176487e-19,
default = "aJ",
},
["feV"] = {
name1 = "femtoelectronvolt",
symbol = "feV",
utype = "energy",
scale = 1.602176487e-34,
default = "yJ",
link = "Electronvolt",
},
["foe"] = {
symbol = "foe",
utype = "energy",
scale = 1e44,
default = "YJ",
link = "Foe (unit)",
},
["ftlb"] = {
name1 = "foot-pound",
symbol = "ft⋅lb",
utype = "energy",
alttype = "torque",
scale = 1.3558179483314004,
default = "J",
link = "Foot-pound (energy)",
},
["ftlb-f"] = {
name1 = "foot-pound force",
name2 = "foot-pounds force",
symbol = "ft⋅lb<sub>f</sub>",
utype = "energy",
alttype = "torque",
scale = 1.3558179483314004,
default = "J",
link = "Foot-pound (energy)",
},
["ftlbf"] = {
name1 = "foot-pound force",
name2 = "foot-pounds force",
symbol = "ft⋅lbf",
utype = "energy",
alttype = "torque",
scale = 1.3558179483314004,
default = "J",
link = "Foot-pound (energy)",
},
["ftpdl"] = {
name1 = "foot-poundal",
symbol = "ft⋅pdl",
utype = "energy",
scale = 0.0421401100938048,
default = "J",
},
["GeV"] = {
name1 = "gigaelectronvolt",
symbol = "GeV",
utype = "energy",
scale = 1.602176487e-10,
default = "nJ",
link = "Electronvolt",
},
["gTNT"] = {
name2 = "grams of TNT",
symbol = "gram of TNT",
usename = 1,
utype = "energy",
scale = 4184,
default = "kJ",
link = "TNT equivalent",
},
["Gtoe"] = {
name1 = "gigatonne of oil equivalent",
name2 = "gigatonnes of oil equivalent",
symbol = "Gtoe",
utype = "energy",
scale = 4.1868e19,
default = "EJ",
link = "Tonne of oil equivalent",
},
["GtonTNT"] = {
name2 = "gigatons of TNT",
symbol = "gigaton of TNT",
usename = 1,
utype = "energy",
scale = 4.184e18,
default = "EJ",
link = "TNT equivalent",
},
["GtTNT"] = {
name2 = "gigatonnes of TNT",
symbol = "gigatonne of TNT",
usename = 1,
utype = "energy",
scale = 4.184e18,
default = "EJ",
link = "TNT equivalent",
},
["GW.h"] = {
name1 = "gigawatt-hour",
symbol = "GW⋅h",
utype = "energy",
scale = 3.6e12,
default = "TJ",
link = "Kilowatt-hour",
},
["GWh"] = {
name1 = "gigawatt-hour",
symbol = "GWh",
utype = "energy",
scale = 3.6e12,
default = "TJ",
link = "Kilowatt-hour",
},
["hph"] = {
name1 = "horsepower-hour",
symbol = "hp⋅h",
utype = "energy",
scale = 2684519.537696172792,
default = "kWh",
link = "Horsepower",
},
["inlb"] = {
name1 = "inch-pound",
symbol = "in⋅lb",
utype = "energy",
alttype = "torque",
scale = 0.1129848290276167,
default = "mJ",
link = "Foot-pound (energy)",
},
["inlb-f"] = {
name1 = "inch-pound force",
name2 = "inch-pounds force",
symbol = "in⋅lb<sub>f</sub>",
utype = "energy",
alttype = "torque",
scale = 0.1129848290276167,
default = "mJ",
link = "Foot-pound (energy)",
},
["inlbf"] = {
name1 = "inch-pound force",
name2 = "inch-pounds force",
symbol = "in⋅lbf",
utype = "energy",
alttype = "torque",
scale = 0.1129848290276167,
default = "mJ",
link = "Foot-pound (energy)",
},
["inoz-f"] = {
name1 = "inch-ounce force",
name2 = "inch-ounces force",
symbol = "in⋅oz<sub>f</sub>",
utype = "energy",
alttype = "torque",
scale = 0.00706155181422604375,
default = "mJ",
link = "Foot-pound (energy)",
},
["inozf"] = {
name1 = "inch-ounce force",
name2 = "inch-ounces force",
symbol = "in⋅ozf",
utype = "energy",
alttype = "torque",
scale = 0.00706155181422604375,
default = "mJ",
link = "Foot-pound (energy)",
},
["J"] = {
_name1 = "joule",
_symbol = "J",
utype = "energy",
scale = 1,
prefixes = 1,
default = "cal",
link = "Joule",
},
["kBOE"] = {
name1 = "kilo barrel of oil equivalent",
name2 = "kilo barrels of oil equivalent",
symbol = "kBOE",
utype = "energy",
scale = 6.1178632e12,
default = "TJ",
link = "Barrel of oil equivalent",
},
["kcal"] = {
name1 = "kilocalorie",
symbol = "kcal",
utype = "energy",
scale = 4184,
default = "kJ",
link = "Calorie",
},
["kcal-15"] = {
name1 = "kilocalorie (15°C)",
name2 = "kilocalories (15°C)",
symbol = "kcal<sub>15</sub>",
utype = "energy",
scale = 4185.8,
default = "kJ",
link = "Calorie",
},
["kcal-IT"] = {
name1 = "kilocalorie (International Steam Table)",
name2 = "kilocalories (International Steam Table)",
symbol = "kcal<sub>IT</sub>",
utype = "energy",
scale = 4186.8,
default = "kJ",
link = "Calorie",
},
["kcal-th"] = {
name1 = "kilocalorie (thermochemical)",
name2 = "kilocalories (thermochemical)",
symbol = "kcal<sub>th</sub>",
utype = "energy",
scale = 4184,
default = "kJ",
link = "Calorie",
},
["kerg"] = {
name1 = "kiloerg",
symbol = "kerg",
utype = "energy",
scale = 0.0001,
default = "mJ",
link = "Erg",
},
["keV"] = {
name1 = "kiloelectronvolt",
symbol = "keV",
utype = "energy",
scale = 1.602176487e-16,
default = "fJ",
link = "Electronvolt",
},
["kgTNT"] = {
name2 = "kilograms of TNT",
symbol = "kilogram of TNT",
usename = 1,
utype = "energy",
scale = 4184000,
default = "MJ",
link = "TNT equivalent",
},
["kt(TNT)"] = {
name1 = "kilotonne",
name1_us = "kiloton",
symbol = "kt",
utype = "energy",
scale = 4.184e12,
default = "TJ",
link = "TNT equivalent",
},
["ktoe"] = {
name1 = "kilotonne of oil equivalent",
name2 = "kilotonnes of oil equivalent",
symbol = "ktoe",
utype = "energy",
scale = 4.1868e13,
default = "TJ",
link = "Tonne of oil equivalent",
},
["ktonTNT"] = {
name1 = "kiloton of TNT",
name2 = "kilotons of TNT",
symbol = "kt",
utype = "energy",
scale = 4.184e12,
default = "TJ",
link = "TNT equivalent",
},
["ktTNT"] = {
name2 = "kilotonnes of TNT",
symbol = "kilotonne of TNT",
usename = 1,
utype = "energy",
scale = 4.184e12,
default = "TJ",
link = "TNT equivalent",
},
["kW.h"] = {
name1 = "kilowatt-hour",
symbol = "kW⋅h",
utype = "energy",
scale = 3600000,
default = "MJ",
},
["kWh"] = {
name1 = "kilowatt-hour",
symbol = "kWh",
utype = "energy",
scale = 3600000,
default = "MJ",
},
["Mcal"] = {
name1 = "megacalorie",
symbol = "Mcal",
utype = "energy",
scale = 4184000,
default = "MJ",
link = "Calorie",
},
["mcal"] = {
name1 = "millicalorie",
symbol = "mcal",
utype = "energy",
scale = 0.004184,
default = "mJ",
link = "Calorie",
},
["Mcal-15"] = {
name1 = "megacalorie (15°C)",
name2 = "megacalories (15°C)",
symbol = "Mcal<sub>15</sub>",
utype = "energy",
scale = 4185800,
default = "MJ",
link = "Calorie",
},
["mcal-15"] = {
name1 = "millicalorie (15°C)",
name2 = "millicalories (15°C)",
symbol = "mcal<sub>15</sub>",
utype = "energy",
scale = 0.0041858,
default = "mJ",
link = "Calorie",
},
["Mcal-IT"] = {
name1 = "megacalorie (International Steam Table)",
name2 = "megacalories (International Steam Table)",
symbol = "Mcal<sub>IT</sub>",
utype = "energy",
scale = 4186800,
default = "MJ",
link = "Calorie",
},
["mcal-IT"] = {
name1 = "millicalorie (International Steam Table)",
name2 = "millicalories (International Steam Table)",
symbol = "mcal<sub>IT</sub>",
utype = "energy",
scale = 0.0041868,
default = "mJ",
link = "Calorie",
},
["Mcal-th"] = {
name1 = "megacalorie (thermochemical)",
name2 = "megacalories (thermochemical)",
symbol = "Mcal<sub>th</sub>",
utype = "energy",
scale = 4184000,
default = "MJ",
link = "Calorie",
},
["mcal-th"] = {
name1 = "millicalorie (thermochemical)",
name2 = "millicalories (thermochemical)",
symbol = "mcal<sub>th</sub>",
utype = "energy",
scale = 0.004184,
default = "mJ",
link = "Calorie",
},
["Merg"] = {
name1 = "megaerg",
symbol = "Merg",
utype = "energy",
scale = 0.1,
default = "J",
link = "Erg",
},
["merg"] = {
name1 = "millierg",
symbol = "merg",
utype = "energy",
scale = 0.0000000001,
default = "μJ",
link = "Erg",
},
["MeV"] = {
name1 = "megaelectronvolt",
symbol = "MeV",
utype = "energy",
scale = 1.602176487e-13,
default = "pJ",
link = "Electronvolt",
},
["meV"] = {
name1 = "millielectronvolt",
symbol = "meV",
utype = "energy",
scale = 1.602176487e-22,
default = "zJ",
link = "Electronvolt",
},
["MMBtu"] = {
name1 = "million British thermal units",
name2 = "million British thermal units",
symbol = "MMBtu",
utype = "energy",
scale = 1055055852.62,
default = "GJ",
link = "British thermal unit",
},
["Mt(TNT)"] = {
name1 = "megatonne",
name1_us = "megaton",
symbol = "Mt",
utype = "energy",
scale = 4.184e15,
default = "PJ",
link = "TNT equivalent",
},
["Mtoe"] = {
name1 = "megatonne of oil equivalent",
name2 = "megatonnes of oil equivalent",
symbol = "Mtoe",
utype = "energy",
scale = 4.1868e16,
default = "PJ",
link = "Tonne of oil equivalent",
},
["MtonTNT"] = {
name1 = "megaton of TNT",
name2 = "megatons of TNT",
symbol = "Mt",
utype = "energy",
scale = 4.184e15,
default = "PJ",
link = "TNT equivalent",
},
["mtonTNT"] = {
name2 = "millitons of TNT",
symbol = "milliton of TNT",
usename = 1,
utype = "energy",
scale = 4184000,
default = "MJ",
link = "TNT equivalent",
},
["MtTNT"] = {
name2 = "megatonnes of TNT",
symbol = "megatonne of TNT",
usename = 1,
utype = "energy",
scale = 4.184e15,
default = "PJ",
link = "TNT equivalent",
},
["mtTNT"] = {
name2 = "millitonnes of TNT",
symbol = "millitonne of TNT",
usename = 1,
utype = "energy",
scale = 4184000,
default = "MJ",
link = "TNT equivalent",
},
["MW.h"] = {
name1 = "megawatt-hour",
symbol = "MW⋅h",
utype = "energy",
scale = 3600000000,
default = "GJ",
link = "Kilowatt-hour",
},
["mW.h"] = {
name1 = "milliwatt-hour",
symbol = "mW⋅h",
utype = "energy",
scale = 3.6,
default = "J",
link = "Kilowatt-hour",
},
["MWh"] = {
name1 = "megawatt-hour",
symbol = "MWh",
utype = "energy",
scale = 3600000000,
default = "GJ",
link = "Kilowatt-hour",
},
["mWh"] = {
name1 = "milliwatt-hour",
symbol = "mWh",
utype = "energy",
scale = 3.6,
default = "J",
link = "Kilowatt-hour",
},
["neV"] = {
name1 = "nanoelectronvolt",
symbol = "neV",
utype = "energy",
scale = 1.602176487e-28,
default = "yJ",
link = "Electronvolt",
},
["PeV"] = {
name1 = "petaelectronvolt",
symbol = "PeV",
utype = "energy",
scale = 0.0001602176487,
default = "mJ",
link = "Electronvolt",
},
["peV"] = {
name1 = "picoelectronvolt",
symbol = "peV",
utype = "energy",
scale = 1.602176487e-31,
default = "yJ",
link = "Electronvolt",
},
["PSh"] = {
name1 = "Pferdestärkenstunde",
symbol = "PSh",
utype = "energy",
scale = 2647795.5,
default = "kWh",
},
["quad"] = {
name1 = "quadrillion British thermal units",
name2 = "quadrillion British thermal units",
symbol = "quad",
utype = "energy",
scale = 1.054804e18,
default = "EJ",
link = "Quad (unit)",
},
["Ry"] = {
name1 = "rydberg",
symbol = "Ry",
utype = "energy",
scale = 2.1798741e-18,
default = "eV",
link = "Rydberg constant",
},
["scf"] = {
name1 = "standard cubic foot",
name2 = "standard cubic feet",
symbol = "scf",
utype = "energy",
scale = 2869.2044809344,
default = "kJ",
},
["scfoot"] = {
name1 = "standard cubic foot",
name2 = "standard cubic foot",
symbol = "scf",
utype = "energy",
scale = 2869.2044809344,
default = "kJ",
},
["t(TNT)"] = {
name1 = "tonne",
name1_us = "ton",
symbol = "t",
utype = "energy",
scale = 4184000000,
default = "GJ",
link = "TNT equivalent",
},
["TeV"] = {
name1 = "teraelectronvolt",
symbol = "TeV",
utype = "energy",
scale = 1.602176487e-7,
default = "μJ",
link = "Electronvolt",
},
["th"] = {
name1 = "thermie",
symbol = "th",
utype = "energy",
scale = 4186800,
default = "MJ",
link = "Conversion of units#Energy",
},
["thm-EC"] = {
name1 = "therm (EC)",
name2 = "therms (EC)",
symbol = "thm (EC)",
utype = "energy",
scale = 105506000,
default = "MJ",
link = "Therm",
},
["thm-UK"] = {
name1 = "therm (UK)",
name2 = "therms (UK)",
symbol = "thm (UK)",
utype = "energy",
scale = 105505585.257348,
default = "MJ",
link = "Therm",
},
["thm-US"] = {
name1 = "therm (US)",
name1_us = "therm (U.S.)",
name2 = "therms (US)",
name2_us = "therms (U.S.)",
symbol = "thm (US)",
sym_us = "thm (U.S.)",
utype = "energy",
scale = 105480400,
default = "MJ",
link = "Therm",
},
["toe"] = {
name1 = "tonne of oil equivalent",
name2 = "tonnes of oil equivalent",
symbol = "toe",
utype = "energy",
scale = 41868000000,
default = "GJ",
},
["tonTNT"] = {
name2 = "tons of TNT",
symbol = "ton of TNT",
usename = 1,
utype = "energy",
scale = 4184000000,
default = "GJ",
link = "TNT equivalent",
},
["tTNT"] = {
name2 = "tonnes of TNT",
symbol = "tonne of TNT",
usename = 1,
utype = "energy",
scale = 4184000000,
default = "GJ",
link = "TNT equivalent",
},
["TtonTNT"] = {
name2 = "teratons of TNT",
symbol = "teraton of TNT",
usename = 1,
utype = "energy",
scale = 4.184e21,
default = "ZJ",
link = "TNT equivalent",
},
["TtTNT"] = {
name2 = "teratonnes of TNT",
symbol = "teratonne of TNT",
usename = 1,
utype = "energy",
scale = 4.184e21,
default = "ZJ",
link = "TNT equivalent",
},
["TW.h"] = {
name1 = "terawatt-hour",
symbol = "TW⋅h",
utype = "energy",
scale = 3.6e15,
default = "PJ",
link = "Kilowatt-hour",
},
["TWh"] = {
name1 = "terawatt-hour",
symbol = "TWh",
utype = "energy",
scale = 3.6e15,
default = "PJ",
link = "Kilowatt-hour",
},
["W.h"] = {
name1 = "watt-hour",
symbol = "W⋅h",
utype = "energy",
scale = 3600,
default = "kJ",
link = "Kilowatt-hour",
},
["Wh"] = {
name1 = "watt-hour",
symbol = "Wh",
utype = "energy",
scale = 3600,
default = "kJ",
link = "Kilowatt-hour",
},
["μerg"] = {
name1 = "microerg",
symbol = "μerg",
utype = "energy",
scale = 1e-13,
default = "nJ",
link = "Erg",
},
["μeV"] = {
name1 = "microelectronvolt",
symbol = "μeV",
utype = "energy",
scale = 1.602176487e-25,
default = "yJ",
link = "Electronvolt",
},
["μW.h"] = {
name1 = "microwatt-hour",
symbol = "μW⋅h",
utype = "energy",
scale = 0.0036,
default = "mJ",
link = "Kilowatt-hour",
},
["μWh"] = {
name1 = "microwatt-hour",
symbol = "μWh",
utype = "energy",
scale = 0.0036,
default = "mJ",
link = "Kilowatt-hour",
},
["-kW.h"] = {
target = "kW.h",
link = "Kilowatt hour",
},
["btu"] = {
target = "BTU",
},
["Calorie"] = {
target = "Cal",
},
["ft.lbf"] = {
target = "ftlbf",
},
["ft·lbf"] = {
target = "ftlbf",
},
["g-cal-15"] = {
target = "cal-15",
},
["g-cal-IT"] = {
target = "cal-IT",
},
["g-cal-th"] = {
target = "cal-th",
},
["g-kcal-15"] = {
target = "kcal-15",
},
["g-kcal-IT"] = {
target = "kcal-IT",
},
["g-kcal-th"] = {
target = "kcal-th",
},
["g-Mcal-15"] = {
target = "Mcal-15",
},
["g-mcal-15"] = {
target = "mcal-15",
},
["g-Mcal-IT"] = {
target = "Mcal-IT",
},
["g-mcal-IT"] = {
target = "mcal-IT",
},
["g-Mcal-th"] = {
target = "Mcal-th",
},
["g-mcal-th"] = {
target = "mcal-th",
},
["GW-h"] = {
target = "GW.h",
},
["GW·h"] = {
target = "GW.h",
},
["Hartree"] = {
target = "Eh",
},
["hp.h"] = {
target = "hph",
},
["in.lb-f"] = {
target = "inlb-f",
},
["in.lbf"] = {
target = "inlbf",
},
["in.oz-f"] = {
target = "inoz-f",
},
["in.ozf"] = {
target = "inozf",
},
["kbboe"] = {
target = "kBOE",
symbol = "kbboe",
},
["kg-cal-15"] = {
target = "Cal-15",
},
["kg-cal-IT"] = {
target = "Cal-IT",
},
["kg-cal-th"] = {
target = "Cal-th",
},
["kW-h"] = {
target = "kW.h",
},
["kW·h"] = {
target = "kW.h",
},
["MW-h"] = {
target = "MW.h",
},
["mW-h"] = {
target = "mW.h",
},
["MW·h"] = {
target = "MW.h",
},
["TW-h"] = {
target = "TW.h",
},
["uerg"] = {
target = "μerg",
},
["ueV"] = {
target = "μeV",
},
["uW-h"] = {
target = "μW.h",
},
["uW.h"] = {
target = "μW.h",
},
["uWh"] = {
target = "μWh",
},
["W-h"] = {
target = "W.h",
},
["eVpar"] = {
_name1 = "electronvolt",
_symbol = "eV",
utype = "energy per chemical amount",
scale = 96485.329522144166,
prefixes = 1,
default = "kcal/mol",
link = "Electronvolt",
},
["kcal/mol"] = {
per = { "kcal", "mol" },
utype = "energy per chemical amount",
default = "kJ/mol",
link = "Kilocalorie per mole",
},
["kJ/mol"] = {
per = { "kJ", "mol" },
utype = "energy per chemical amount",
default = "kcal/mol",
link = "Joule per mole",
},
["kWh/100 km"] = {
name1 = "kilowatt-hour per 100 kilometres",
name1_us = "kilowatt-hour per 100 kilometers",
name2 = "kilowatt-hours per 100 kilometres",
name2_us = "kilowatt-hours per 100 kilometers",
symbol = "kW⋅h/100 km",
utype = "energy per unit length",
scale = 36,
default = "MJ/km kWh/mi",
link = "Kilowatt-hour",
},
["kWh/100 mi"] = {
name1 = "kilowatt-hour per 100 miles",
name2 = "kilowatt-hours per 100 miles",
symbol = "kW⋅h/100 mi",
utype = "energy per unit length",
scale = 22.3694,
default = "mpge",
link = "Miles per gallon gasoline equivalent",
},
["MJ/100 km"] = {
name1 = "megajoule per 100 kilometres",
name1_us = "megajoule per 100 kilometers",
name2 = "megajoules per 100 kilometres",
name2_us = "megajoules per 100 kilometers",
symbol = "MJ/100 km",
utype = "energy per unit length",
scale = 10,
default = "BTU/mi",
link = "British thermal unit",
},
["mpge"] = {
name1 = "mile per gallon gasoline equivalent",
name2 = "miles per gallon gasoline equivalent",
symbol = "mpg‑e",
utype = "energy per unit length",
scale = 1.3263314048360777e-5,
invert = -1,
iscomplex= true,
default = "kWh/100 mi",
link = "Miles per gallon gasoline equivalent",
},
["BTU/mi"] = {
per = { "BTU", "mi" },
utype = "energy per unit length",
default = "v > 1525 ! M ! k ! J/km",
},
["kJ/km"] = {
per = { "kJ", "km" },
utype = "energy per unit length",
default = "BTU/mi",
},
["kWh/km"] = {
per = { "-kW.h", "km" },
utype = "energy per unit length",
default = "MJ/km kWh/mi",
},
["kWh/mi"] = {
per = { "-kW.h", "mi" },
utype = "energy per unit length",
default = "kWh/km MJ/km",
},
["MJ/km"] = {
per = { "MJ", "km" },
utype = "energy per unit length",
default = "BTU/mi",
},
["mpg-e"] = {
target = "mpge",
},
["BTU/lb"] = {
name1 = "British thermal unit per pound",
name2 = "British thermal units per pound",
symbol = "BTU/lb",
utype = "energy per unit mass",
scale = 2326,
default = "kJ/kg",
link = "British thermal unit",
},
["cal/g"] = {
name1 = "calorie per gram",
name2 = "calories per gram",
symbol = "cal/g",
utype = "energy per unit mass",
scale = 4184,
default = "J/g",
},
["GJ/kg"] = {
name1 = "gigajoule per kilogram",
name2 = "gigajoules per kilogram",
symbol = "GJ/kg",
utype = "energy per unit mass",
scale = 1e9,
default = "ktTNT/t",
link = "Specific energy",
},
["J/g"] = {
name1 = "joule per gram",
name2 = "joules per gram",
symbol = "J/g",
utype = "energy per unit mass",
scale = 1000,
default = "kcal/g",
link = "Specific energy",
},
["kcal/g"] = {
name1 = "kilocalorie per gram",
name2 = "kilocalories per gram",
symbol = "kcal/g",
utype = "energy per unit mass",
scale = 4184000,
default = "kJ/g",
},
["kJ/g"] = {
name1 = "kilojoule per gram",
name2 = "kilojoules per gram",
symbol = "kJ/g",
utype = "energy per unit mass",
scale = 1000000,
default = "kcal/g",
link = "Specific energy",
},
["kJ/kg"] = {
name1 = "kilojoule per kilogram",
name2 = "kilojoules per kilogram",
symbol = "kJ/kg",
utype = "energy per unit mass",
scale = 1000,
default = "BTU/lb",
link = "Specific energy",
},
["ktonTNT/MT"] = {
name2 = "kilotons of TNT per metric ton",
symbol = "kiloton of TNT per metric ton",
usename = 1,
utype = "energy per unit mass",
scale = 4184000000,
default = "GJ/kg",
link = "TNT equivalent",
},
["ktTNT/t"] = {
name2 = "kilotonnes of TNT per tonne",
symbol = "kilotonne of TNT per tonne",
usename = 1,
utype = "energy per unit mass",
scale = 4184000000,
default = "GJ/kg",
link = "TNT equivalent",
},
["MtonTNT/MT"] = {
name2 = "megatons of TNT per metric ton",
symbol = "megaton of TNT per metric ton",
usename = 1,
utype = "energy per unit mass",
scale = 4.184e12,
default = "TJ/kg",
link = "TNT equivalent",
},
["MtTNT/MT"] = {
name2 = "megatonnes of TNT per tonne",
symbol = "megatonne of TNT per tonne",
usename = 1,
utype = "energy per unit mass",
scale = 4.184e12,
default = "TJ/kg",
link = "TNT equivalent",
},
["TJ/kg"] = {
name1 = "terajoule per kilogram",
name2 = "terajoules per kilogram",
symbol = "TJ/kg",
utype = "energy per unit mass",
scale = 1e12,
default = "MtTNT/MT",
link = "Specific energy",
},
["Cal/g"] = {
per = { "Cal", "g" },
utype = "energy per unit mass",
default = "kJ/g",
},
["BTU/cuft"] = {
per = { "BTU", "cuft" },
utype = "energy per unit volume",
default = "kJ/L",
},
["Cal/12USoz(mL)serve"] = {
per = { "Cal", "-12USoz(mL)serve" },
utype = "energy per unit volume",
default = "kJ/L",
},
["Cal/12USoz(ml)serve"] = {
per = { "Cal", "-12USoz(ml)serve" },
utype = "energy per unit volume",
default = "kJ/l",
},
["Cal/12USozserve"] = {
per = { "Cal", "-12USozserve" },
utype = "energy per unit volume",
default = "kJ/L",
},
["Cal/USoz"] = {
per = { "Cal", "USoz" },
utype = "energy per unit volume",
default = "kJ/ml",
},
["kJ/L"] = {
per = { "kJ", "L" },
utype = "energy per unit volume",
default = "BTU/cuft",
},
["kJ/l"] = {
per = { "kJ", "ll" },
utype = "energy per unit volume",
default = "BTU/cuft",
},
["kJ/ml"] = {
per = { "kJ", "ml" },
utype = "energy per unit volume",
default = "Cal/USoz",
},
["MJ/m3"] = {
per = { "MJ", "m3" },
utype = "energy per unit volume",
default = "BTU/cuft",
},
["Sv"] = {
_name1 = "sievert",
_symbol = "Sv",
utype = "equivalent radiation dose",
scale = 1,
prefixes = 1,
default = "rem",
link = "Sievert",
},
["rem"] = {
_name1 = "rem",
_symbol = "rem",
utype = "equivalent radiation dose",
scale = 0.01,
prefixes = 1,
default = "Sv",
link = "Roentgen equivalent man",
},
["g/km"] = {
name1 = "gram per kilometre",
name1_us = "gram per kilometer",
name2 = "grams per kilometre",
name2_us = "grams per kilometer",
symbol = "g/km",
utype = "exhaust emission",
scale = 1e-6,
default = "oz/mi",
link = "Exhaust gas",
},
["g/mi"] = {
name1 = "gram per mile",
name2 = "grams per mile",
symbol = "g/mi",
utype = "exhaust emission",
scale = 6.2137119223733397e-7,
default = "g/km",
link = "Exhaust gas",
},
["gCO2/km"] = {
name1 = "gram of CO<sub>2</sub> per kilometre",
name1_us = "gram of CO<sub>2</sub> per kilometer",
name2 = "grams of CO<sub>2</sub> per kilometre",
name2_us = "grams of CO<sub>2</sub> per kilometer",
symbol = "g(CO<sub>2</sub>)/km",
utype = "exhaust emission",
scale = 1e-6,
default = "ozCO2/mi",
link = "Exhaust gas",
},
["gCO2/mi"] = {
name1 = "gram of CO<sub>2</sub> per mile",
name2 = "grams of CO<sub>2</sub> per mile",
symbol = "g(CO<sub>2</sub>)/mi",
utype = "exhaust emission",
scale = 6.2137119223733397e-7,
default = "gCO2/km",
link = "Exhaust gas",
},
["kg/km"] = {
name1 = "kilogram per kilometre",
name1_us = "kilogram per kilometer",
name2 = "kilograms per kilometre",
name2_us = "kilograms per kilometer",
symbol = "kg/km",
utype = "exhaust emission",
scale = 0.001,
default = "lb/mi",
link = "Exhaust gas",
},
["kgCO2/km"] = {
name1 = "kilogram of CO<sub>2</sub> per kilometre",
name1_us = "kilogram of CO<sub>2</sub> per kilometer",
name2 = "kilograms of CO<sub>2</sub> per kilometre",
name2_us = "kilograms of CO<sub>2</sub> per kilometer",
symbol = "kg(CO<sub>2</sub>)/km",
utype = "exhaust emission",
scale = 0.001,
default = "lbCO2/mi",
link = "Exhaust gas",
},
["lb/mi"] = {
name1 = "pound per mile",
name2 = "pounds per mile",
symbol = "lb/mi",
utype = "exhaust emission",
scale = 0.00028184923173665794,
default = "kg/km",
link = "Exhaust gas",
},
["lbCO2/mi"] = {
name1 = "pound of CO<sub>2</sub> per mile",
name2 = "pounds of CO<sub>2</sub> per mile",
symbol = "lb(CO<sub>2</sub>)/mi",
utype = "exhaust emission",
scale = 0.00028184923173665794,
default = "kgCO2/km",
link = "Exhaust gas",
},
["oz/mi"] = {
name1 = "ounce per mile",
name2 = "ounces per mile",
symbol = "oz/mi",
utype = "exhaust emission",
scale = 1.7615576983541121e-5,
default = "g/km",
link = "Exhaust gas",
},
["ozCO2/mi"] = {
name1 = "ounce of CO<sub>2</sub> per mile",
name2 = "ounces of CO<sub>2</sub> per mile",
symbol = "oz(CO<sub>2</sub>)/mi",
utype = "exhaust emission",
scale = 1.7615576983541121e-5,
default = "gCO2/km",
link = "Exhaust gas",
},
["cuft/a"] = {
name1 = "cubic foot per annum",
name2 = "cubic feet per annum",
symbol = "cu ft/a",
utype = "flow",
scale = 8.9730672142368242e-10,
default = "m3/a",
link = "Cubic foot per second",
},
["cuft/d"] = {
name1 = "cubic foot per day",
name2 = "cubic feet per day",
symbol = "cu ft/d",
utype = "flow",
scale = 3.2774128000000003e-7,
default = "m3/d",
link = "Cubic foot per second",
},
["cuft/h"] = {
name1 = "cubic foot per hour",
name2 = "cubic feet per hour",
symbol = "cu ft/h",
utype = "flow",
scale = 7.8657907200000004e-6,
default = "m3/h",
link = "Cubic foot per second",
},
["cuft/min"] = {
name1 = "cubic foot per minute",
name2 = "cubic feet per minute",
symbol = "cu ft/min",
utype = "flow",
scale = 0.00047194744319999999,
default = "m3/min",
},
["cuft/s"] = {
name1 = "cubic foot per second",
name2 = "cubic feet per second",
symbol = "cu ft/s",
utype = "flow",
scale = 28316846592e-12,
default = "m3/s",
},
["cumi/a"] = {
name1 = "cubic mile per annum",
name2 = "cubic miles per annum",
symbol = "cu mi/a",
utype = "flow",
scale = 132.08171170940057,
default = "km3/a",
link = "Cubic foot per second",
},
["cuyd/h"] = {
name1 = "cubic yard per hour",
name2 = "cubic yards per hour",
symbol = "cuyd/h",
utype = "flow",
scale = 0.00021237634944000001,
default = "m3/h",
link = "Cubic foot per second",
},
["cuyd/s"] = {
name1 = "cubic yard per second",
name2 = "cubic yards per second",
symbol = "cu yd/s",
utype = "flow",
scale = 0.76455485798400002,
default = "m3/s",
},
["Goilbbl/a"] = {
name1 = "billion barrels per year",
name2 = "billion barrels per year",
symbol = "Gbbl/a",
utype = "flow",
scale = 5.0380033629933836,
default = "v * 1.58987294928 < 10 ! e6 ! e9 ! m3/a",
link = "Barrel per day",
},
["impgal/h"] = {
name1 = "imperial gallon per hour",
name2 = "imperial gallons per hour",
symbol = "imp gal/h",
utype = "flow",
scale = 1.2628027777777779e-6,
default = "m3/h",
link = "Gallon",
},
["impgal/min"] = {
name1 = "imperial gallon per minute",
name2 = "imperial gallons per minute",
symbol = "imp gal/min",
utype = "flow",
scale = 7.5768166666666671e-5,
default = "m3/s",
link = "Gallon",
},
["impgal/s"] = {
name1 = "imperial gallon per second",
name2 = "imperial gallons per second",
symbol = "impgal/s",
utype = "flow",
scale = 0.00454609,
default = "m3/s",
link = "Imperial gallons per second",
},
["km3/a"] = {
name1 = "cubic kilometre per annum",
name1_us = "cubic kilometer per annum",
name2 = "cubic kilometres per annum",
name2_us = "cubic kilometers per annum",
symbol = "km<sup>3</sup>/a",
utype = "flow",
scale = 31.68808781402895,
default = "cumi/a",
link = "Cubic metre per second",
},
["km3/d"] = {
name1 = "cubic kilometre per day",
name1_us = "cubic kilometer per day",
name2 = "cubic kilometres per day",
name2_us = "cubic kilometers per day",
symbol = "km<sup>3</sup>/d",
utype = "flow",
scale = 11574.074074074075,
default = "cuft/d",
link = "Cubic metre per second",
},
["koilbbl/a"] = {
name1 = "thousand barrels per year",
name2 = "thousand barrels per year",
symbol = "kbbl/a",
utype = "flow",
scale = 5.0380033629933841e-6,
default = "v * 1.58987294928 < 10 ! ! e3 ! m3/a",
link = "Barrel per day",
},
["koilbbl/d"] = {
name1 = "thousand barrels per day",
name2 = "thousand barrels per day",
symbol = "kbbl/d",
utype = "flow",
scale = 0.0018401307283333335,
default = "v * 1.58987294928 < 10 ! ! e3 ! m3/d",
link = "Barrel per day",
},
["L/h"] = {
name1 = "litre per hour",
name1_us = "liter per hour",
name2 = "litres per hour",
name2_us = "liters per hour",
symbol = "L/h",
utype = "flow",
scale = 2.7777777777777776e-7,
default = "impgal/h USgal/h",
link = "Cubic metre per second",
},
["L/min"] = {
name1 = "litre per minute",
name1_us = "liter per minute",
name2 = "litres per minute",
name2_us = "liters per minute",
symbol = "L/min",
utype = "flow",
scale = 1.6666666666666667e-5,
default = "impgal/min USgal/min",
link = "Cubic metre per second",
},
["L/s"] = {
name1 = "litre per second",
name1_us = "liter per second",
name2 = "litres per second",
name2_us = "liters per second",
symbol = "L/s",
utype = "flow",
scale = 0.001,
default = "cuft/s",
link = "Cubic metre per second",
},
["m3/a"] = {
name1 = "cubic metre per annum",
name1_us = "cubic meter per annum",
name2 = "cubic metres per annum",
name2_us = "cubic meters per annum",
symbol = "m<sup>3</sup>/a",
utype = "flow",
scale = 3.1688087814028947e-8,
default = "cuft/a",
link = "Cubic metre per second",
},
["m3/d"] = {
name1 = "cubic metre per day",
name1_us = "cubic meter per day",
name2 = "cubic metres per day",
name2_us = "cubic meters per day",
symbol = "m<sup>3</sup>/d",
utype = "flow",
scale = 1.1574074074074073e-5,
default = "cuft/d",
link = "Cubic metre per second",
},
["m3/h"] = {
name1 = "cubic metre per hour",
name1_us = "cubic meter per hour",
name2 = "cubic metres per hour",
name2_us = "cubic meters per hour",
symbol = "m<sup>3</sup>/h",
utype = "flow",
scale = 0.00027777777777777778,
default = "cuft/h",
link = "Cubic metre per second",
},
["m3/min"] = {
name1 = "cubic metre per minute",
name1_us = "cubic meter per minute",
name2 = "cubic metres per minute",
name2_us = "cubic meters per minute",
symbol = "m<sup>3</sup>/min",
utype = "flow",
scale = 0.016666666666666666,
default = "cuft/min",
link = "Cubic metre per second",
},
["m3/s"] = {
name1 = "cubic metre per second",
name1_us = "cubic meter per second",
name2 = "cubic metres per second",
name2_us = "cubic meters per second",
symbol = "m<sup>3</sup>/s",
utype = "flow",
scale = 1,
default = "cuft/s",
},
["Moilbbl/a"] = {
name1 = "million barrels per year",
name2 = "million barrels per year",
symbol = "Mbbl/a",
utype = "flow",
scale = 0.0050380033629933837,
default = "v * 1.58987294928 < 10 ! e3 ! e6 ! m3/a",
link = "Barrel per day",
},
["Moilbbl/d"] = {
name1 = "million barrels per day",
name2 = "million barrels per day",
symbol = "Mbbl/d",
utype = "flow",
scale = 1.8401307283333335,
default = "v * 1.58987294928 < 10 ! e3 ! e6 ! m3/d",
link = "Barrel per day",
},
["oilbbl/a"] = {
name1 = "barrel per year",
name2 = "barrels per year",
symbol = "bbl/a",
utype = "flow",
scale = 5.0380033629933841e-9,
default = "m3/a",
link = "Barrel per day",
},
["oilbbl/d"] = {
name1 = "barrel per day",
name2 = "barrels per day",
symbol = "bbl/d",
utype = "flow",
scale = 1.8401307283333336e-6,
default = "m3/d",
},
["Toilbbl/a"] = {
name1 = "trillion barrels per year",
name2 = "trillion barrels per year",
symbol = "Tbbl/a",
utype = "flow",
scale = 5038.0033629933832,
default = "v * 1.58987294928 < 10 ! e9 ! e12 ! m3/a",
link = "Barrel per day",
},
["U.S.gal/d"] = {
name1 = "U.S. gallon per day",
name2 = "U.S. gallons per day",
symbol = "U.S. gal/d",
utype = "flow",
scale = 4.3812636388888893e-8,
default = "m3/s",
customary= 1,
},
["U.S.gal/h"] = {
name1 = "gallon per hour",
name2 = "gallons per hour",
symbol = "gal/h",
utype = "flow",
scale = 1.0515032733333334e-6,
default = "m3/h",
link = "Gallon",
customary= 2,
},
["U.S.gal/min"] = {
name1 = "U.S. gallon per minute",
name2 = "U.S. gallons per minute",
symbol = "U.S. gal/min",
utype = "flow",
scale = 6.3090196400000003e-5,
default = "m3/s",
link = "Gallon",
},
["USgal/a"] = {
name1 = "US gallon per year",
name2 = "US gallons per year",
symbol = "US gal/a",
utype = "flow",
scale = 1.1995246102365199e-10,
default = "m3/s",
},
["USgal/d"] = {
name1 = "US gallon per day",
name2 = "US gallons per day",
symbol = "US gal/d",
utype = "flow",
scale = 4.3812636388888893e-8,
default = "m3/s",
},
["USgal/h"] = {
name1 = "gallon per hour",
name2 = "gallons per hour",
symbol = "gal/h",
utype = "flow",
scale = 1.0515032733333334e-6,
default = "m3/h",
link = "Gallon",
customary= 1,
},
["USgal/min"] = {
name1 = "US gallon per minute",
name2 = "US gallons per minute",
symbol = "US gal/min",
utype = "flow",
scale = 6.3090196400000003e-5,
default = "m3/s",
link = "Gallon",
},
["USgal/s"] = {
name1 = "US gallon per second",
name1_us = "U.S. gallon per second",
name2 = "US gallons per second",
name2_us = "U.S. gallons per second",
symbol = "USgal/s",
utype = "flow",
scale = 0.003785411784,
default = "m3/s",
link = "US gallons per second",
},
["ft3/a"] = {
target = "cuft/a",
},
["ft3/d"] = {
target = "cuft/d",
},
["ft3/h"] = {
target = "cuft/h",
},
["ft3/s"] = {
target = "cuft/s",
},
["Gcuft/a"] = {
target = "e9cuft/a",
},
["Gcuft/d"] = {
target = "e9cuft/d",
},
["kcuft/a"] = {
target = "e3cuft/a",
},
["kcuft/d"] = {
target = "e3cuft/d",
},
["kcuft/s"] = {
target = "e3cuft/s",
},
["Mcuft/a"] = {
target = "e6cuft/a",
},
["Mcuft/d"] = {
target = "e6cuft/d",
},
["Mcuft/s"] = {
target = "e6cuft/s",
},
["m³/s"] = {
target = "m3/s",
},
["Tcuft/a"] = {
target = "e12cuft/a",
},
["Tcuft/d"] = {
target = "e12cuft/d",
},
["u.s.gal/min"] = {
target = "U.S.gal/min",
},
["usgal/min"] = {
target = "USgal/min",
},
["-LTf"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "LTf",
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["-STf"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "STf",
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["dyn"] = {
name1 = "dyne",
symbol = "dyn",
utype = "force",
scale = 0.00001,
default = "gr-f",
},
["g-f"] = {
name1 = "gram-force",
name2 = "grams-force",
symbol = "g<sub>f</sub>",
utype = "force",
scale = 0.00980665,
default = "mN oz-f",
link = "Kilogram-force",
},
["gf"] = {
name1 = "gram-force",
name2 = "grams-force",
symbol = "gf",
utype = "force",
scale = 0.00980665,
default = "mN ozf",
link = "Kilogram-force",
},
["gr-f"] = {
name1 = "grain-force",
name2 = "grains-force",
symbol = "gr<sub>f</sub>",
utype = "force",
scale = 0.0006354602307515,
default = "μN",
link = "Pound (force)",
},
["grf"] = {
name1 = "grain-force",
name2 = "grains-force",
symbol = "grf",
utype = "force",
scale = 0.0006354602307515,
default = "μN",
link = "Pound (force)",
},
["kdyn"] = {
name1 = "kilodyne",
symbol = "kdyn",
utype = "force",
scale = 0.01,
default = "oz-f",
link = "Dyne",
},
["kg-f"] = {
name1 = "kilogram-force",
name2 = "kilograms-force",
symbol = "kg<sub>f</sub>",
utype = "force",
scale = 9.80665,
default = "N lb-f",
},
["kgf"] = {
name1 = "kilogram-force",
name2 = "kilograms-force",
symbol = "kgf",
utype = "force",
scale = 9.80665,
default = "N lbf",
},
["kp"] = {
name1 = "kilopond",
symbol = "kp",
utype = "force",
scale = 9.80665,
default = "N lb-f",
link = "Kilogram-force",
},
["L/T-f"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "L/T<sub>f</sub>",
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["L/Tf"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "L/Tf",
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["lb-f"] = {
name1 = "pound-force",
name2 = "pounds-force",
symbol = "lb<sub>f</sub>",
utype = "force",
scale = 4.4482216152605,
default = "N",
link = "Pound (force)",
},
["lbf"] = {
name1 = "pound-force",
name2 = "pounds-force",
symbol = "lbf",
utype = "force",
scale = 4.4482216152605,
default = "N",
link = "Pound (force)",
},
["lb(f)"] = {
name1 = "pound",
symbol = "lb",
utype = "force",
scale = 4.4482216152605,
default = "N",
link = "Pound (force)",
},
["LT-f"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "LT<sub>f</sub>",
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["LTf"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "LTf",
usename = 1,
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["Mdyn"] = {
name1 = "megadyne",
symbol = "Mdyn",
utype = "force",
scale = 10,
default = "lb-f",
link = "Dyne",
},
["mdyn"] = {
name1 = "millidyne",
symbol = "mdyn",
utype = "force",
scale = 0.00000001,
default = "gr-f",
link = "Dyne",
},
["mg-f"] = {
name1 = "milligram-force",
name2 = "milligrams-force",
symbol = "mg<sub>f</sub>",
utype = "force",
scale = 0.00000980665,
default = "μN gr-f",
link = "Kilogram-force",
},
["mgf"] = {
name1 = "milligram-force",
name2 = "milligrams-force",
symbol = "mgf",
utype = "force",
scale = 0.00000980665,
default = "μN grf",
link = "Kilogram-force",
},
["Mp"] = {
name1 = "megapond",
symbol = "Mp",
utype = "force",
scale = 9806.65,
default = "kN LT-f ST-f",
link = "Kilogram-force",
},
["mp"] = {
name1 = "millipond",
symbol = "mp",
utype = "force",
scale = 0.00000980665,
default = "μN gr-f",
link = "Kilogram-force",
},
["N"] = {
_name1 = "newton",
_symbol = "N",
utype = "force",
scale = 1,
prefixes = 1,
default = "lb-f",
link = "Newton (unit)",
},
["oz-f"] = {
name1 = "ounce-force",
name2 = "ounces-force",
symbol = "oz<sub>f</sub>",
utype = "force",
scale = 0.2780138203095378125,
default = "mN",
link = "Pound (force)",
},
["ozf"] = {
name1 = "ounce-force",
name2 = "ounces-force",
symbol = "ozf",
utype = "force",
scale = 0.2780138203095378125,
default = "mN",
link = "Pound (force)",
},
["p"] = {
name1 = "pond",
symbol = "p",
utype = "force",
scale = 0.00980665,
default = "mN oz-f",
link = "Kilogram-force",
},
["pdl"] = {
name1 = "poundal",
symbol = "pdl",
utype = "force",
scale = 0.138254954376,
default = "N",
},
["S/T-f"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "S/T<sub>f</sub>",
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["S/Tf"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "S/Tf",
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["ST-f"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "ST<sub>f</sub>",
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["STf"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "STf",
usename = 1,
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["t-f"] = {
name1 = "tonne-force",
name2 = "tonnes-force",
symbol = "t<sub>f</sub>",
utype = "force",
scale = 9806.65,
default = "kN LT-f ST-f",
link = "Ton-force#Tonne-force",
},
["tf"] = {
name1 = "tonne-force",
name2 = "tonnes-force",
symbol = "tf",
utype = "force",
scale = 9806.65,
default = "kN LTf STf",
link = "Ton-force#Tonne-force",
},
["dyne"] = {
target = "dyn",
},
["newtons"] = {
target = "N",
},
["poundal"] = {
target = "pdl",
},
["tonne-force"] = {
target = "tf",
},
["impgal/mi"] = {
per = { "@impgal", "mi" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "L/km USgal/mi",
},
["km/L"] = {
per = { "km", "L" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "mpgimp mpgus",
},
["km/l"] = {
per = { "km", "ll" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "mpgimp mpgus",
},
["L/100 km"] = {
per = { "L", "100km" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "mpgimp mpgus",
symlink = "[[Fuel economy in automobiles#Units of measure|L/100 km]]",
},
["l/100 km"] = {
per = { "ll", "100km" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "mpgimp mpgus",
symlink = "[[Fuel economy in automobiles#Units of measure|l/100 km]]",
},
["L/km"] = {
per = { "L", "km" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "mpgimp mpgus",
},
["l/km"] = {
per = { "ll", "km" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "mpgimp mpgus",
},
["mi/impqt"] = {
per = { "mi", "impqt" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "km/L",
},
["mi/U.S.qt"] = {
per = { "mi", "U.S.qt" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "km/L",
},
["mi/USqt"] = {
per = { "mi", "USqt" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "km/L",
},
["mi/usqt"] = {
per = { "mi", "usqt" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "km/L",
},
["mpgimp"] = {
per = { "mi", "@impgal" },
symbol = "mpg<sub>‑imp</sub>",
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "L/100 km+mpgus",
symlink = "[[Fuel economy in automobiles#Units of measure|mpg]]<sub>‑[[Imperial units|imp]]</sub>",
},
["mpgus"] = {
per = { "mi", "+USgal" },
symbol = "mpg<sub>‑US</sub>",
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "L/100 km+mpgimp",
symlink = "[[Fuel economy in automobiles#Units of measure|mpg]]<sub>‑[[United States customary units|US]]</sub>",
},
["U.S.gal/mi"] = {
per = { "*U.S.gal", "mi" },
sp_us = true,
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "L/km impgal/mi",
},
["usgal/mi"] = {
per = { "+USgal", "mi" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "L/km impgal/mi",
},
["L/100km"] = {
target = "L/100 km",
},
["l/100km"] = {
target = "l/100 km",
},
["mpg"] = {
shouldbe = "Use %{mpgus%} for miles per US gallon or %{mpgimp%} for miles per imperial gallon (not %{mpg%})",
},
["mpgU.S."] = {
target = "mpgus",
symbol = "mpg<sub>‑U.S.</sub>",
sp_us = true,
symlink = "[[Fuel economy in automobiles#Units of measure|mpg]]<sub>‑[[United States customary units|U.S.]]</sub>",
},
["mpgu.s."] = {
target = "mpgus",
symbol = "mpg<sub>‑U.S.</sub>",
sp_us = true,
symlink = "[[Fuel economy in automobiles#Units of measure|mpg]]<sub>‑[[United States customary units|U.S.]]</sub>",
},
["mpgUS"] = {
target = "mpgus",
},
["USgal/mi"] = {
target = "usgal/mi",
},
["kPa/m"] = {
per = { "kPa", "-m-frac" },
utype = "fracture gradient",
default = "psi/ft",
},
["psi/ft"] = {
per = { "psi", "-ft-frac" },
utype = "fracture gradient",
default = "kPa/m",
},
["cm/km"] = {
name1 = "centimetre per kilometre",
name1_us = "centimeter per kilometer",
name2 = "centimetres per kilometre",
name2_us = "centimeters per kilometer",
symbol = "cm/km",
utype = "gradient",
scale = 0.00001,
default = "ft/mi",
link = "Grade (slope)",
},
["ft/mi"] = {
name1 = "foot per mile",
name2 = "feet per mile",
symbol = "ft/mi",
utype = "gradient",
scale = 0.00018939393939393939,
default = "v < 5.28 ! c ! ! m/km",
link = "Grade (slope)",
},
["ft/nmi"] = {
name1 = "foot per nautical mile",
name2 = "feet per nautical mile",
symbol = "ft/nmi",
utype = "gradient",
scale = 0.00016457883369330455,
default = "v < 6.076 ! c ! ! m/km",
link = "Grade (slope)",
},
["in/ft"] = {
name1 = "inch per foot",
name2 = "inches per foot",
symbol = "in/ft",
utype = "gradient",
scale = 0.083333333333333329,
default = "mm/m",
link = "Grade (slope)",
},
["in/mi"] = {
name1 = "inch per mile",
name2 = "inches per mile",
symbol = "in/mi",
utype = "gradient",
scale = 1.5782828282828283e-5,
default = "v < 0.6336 ! m ! c ! m/km",
link = "Grade (slope)",
},
["m/km"] = {
name1 = "metre per kilometre",
name1_us = "meter per kilometer",
name2 = "metres per kilometre",
name2_us = "meters per kilometer",
symbol = "m/km",
utype = "gradient",
scale = 0.001,
default = "ft/mi",
link = "Grade (slope)",
},
["mm/km"] = {
name1 = "millimetre per kilometre",
name1_us = "millimeter per kilometer",
name2 = "millimetres per kilometre",
name2_us = "millimeters per kilometer",
symbol = "mm/km",
utype = "gradient",
scale = 0.000001,
default = "in/mi",
link = "Grade (slope)",
},
["mm/m"] = {
name1 = "millimetre per metre",
name1_us = "millimeter per meter",
name2 = "millimetres per metre",
name2_us = "millimeters per meter",
symbol = "mm/m",
utype = "gradient",
scale = 0.001,
default = "in/ft",
link = "Grade (slope)",
},
["admi"] = {
name1 = "admiralty mile",
symbol = "nmi (admiralty)",
utype = "length",
scale = 1853.184,
default = "km mi",
link = "Nautical mile",
},
["AU"] = {
name1 = "astronomical unit",
symbol = "AU",
utype = "length",
scale = 149597870700,
default = "km mi",
},
["Brnmi"] = {
name1 = "British nautical mile",
symbol = "(Brit) nmi",
utype = "length",
scale = 1853.184,
default = "km mi",
link = "Nautical mile",
},
["bu"] = {
name2 = "bu",
symbol = "bu",
usename = 1,
utype = "length",
scale = 0.0030303030303030303,
default = "mm",
link = "Japanese units of measurement#Length",
},
["ch"] = {
name1 = "chain",
symbol = "ch",
utype = "length",
scale = 20.1168,
default = "ft m",
subdivs = { ["ft"] = { 66, default = "m" }, ["yd"] = { 22, default = "m" } },
link = "Chain (unit)",
},
["chlk"] = {
name1 = "[[Chain (unit)|chain]]",
symbol = "[[Chain (unit)|ch]]",
utype = "length",
scale = 20.1168,
default = "ft m",
link = "",
},
["chain"] = {
symbol = "chain",
usename = 1,
utype = "length",
scale = 20.1168,
default = "ft m",
subdivs = { ["ft"] = { 66, default = "m" }, ["yd"] = { 22, default = "m" } },
link = "Chain (unit)",
},
["chainlk"] = {
symbol = "[[Chain (unit)|chain]]",
usename = 1,
utype = "length",
scale = 20.1168,
default = "ft m",
link = "",
},
["dpcm"] = {
name2 = "dot/cm",
symbol = "dot/cm",
utype = "length",
scale = 100,
invert = -1,
iscomplex= true,
default = "dpi",
link = "Dots per inch",
},
["dpi"] = {
name2 = "DPI",
symbol = "DPI",
utype = "length",
scale = 39.370078740157481,
invert = -1,
iscomplex= true,
default = "pitch",
link = "Dots per inch",
},
["fathom"] = {
symbol = "fathom",
usename = 1,
utype = "length",
scale = 1.8288,
default = "ft m",
},
["foot"] = {
name1 = "foot",
name2 = "foot",
symbol = "ft",
utype = "length",
scale = 0.3048,
default = "m",
subdivs = { ["in"] = { 12, default = "m" } },
link = "Foot (unit)",
},
["ft"] = {
name1 = "foot",
name2 = "feet",
symbol = "ft",
utype = "length",
scale = 0.3048,
exception= "integer_more_precision",
default = "m",
subdivs = { ["in"] = { 12, default = "m" } },
link = "Foot (unit)",
},
["furlong"] = {
symbol = "furlong",
usename = 1,
utype = "length",
scale = 201.168,
default = "ft m",
},
["Gly"] = {
name1 = "gigalight-year",
symbol = "Gly",
utype = "length",
scale = 9.4607304725808e24,
default = "Mpc",
link = "Light-year#Definitions",
},
["Gpc"] = {
name1 = "gigaparsec",
symbol = "Gpc",
utype = "length",
scale = 3.0856775814671916e25,
default = "Gly",
link = "Parsec#Megaparsecs and gigaparsecs",
},
["hand"] = {
name1 = "hand",
symbol = "h",
utype = "length",
builtin = "hand",
scale = 0.1016,
iscomplex= true,
default = "in cm",
link = "Hand (unit)",
},
["in"] = {
name1 = "inch",
name2 = "inches",
symbol = "in",
utype = "length",
scale = 0.0254,
exception= "subunit_more_precision",
default = "mm",
},
["inabbreviated"] = {
name2 = "in",
symbol = "in",
utype = "length",
scale = 0.0254,
default = "mm",
link = "Inch",
},
["kly"] = {
name1 = "kilolight-year",
symbol = "kly",
utype = "length",
scale = 9.4607304725808e18,
default = "pc",
link = "Light-year#Definitions",
},
["kpc"] = {
name1 = "kiloparsec",
symbol = "kpc",
utype = "length",
scale = 3.0856775814671916e19,
default = "kly",
link = "Parsec#Parsecs and kiloparsecs",
},
["LD"] = {
name1 = "lunar distance",
symbol = "LD",
utype = "length",
scale = 384403000,
default = "km mi",
link = "Lunar distance (astronomy)",
},
["league"] = {
symbol = "league",
usename = 1,
utype = "length",
scale = 4828.032,
default = "km",
link = "League (unit)",
},
["ly"] = {
name1 = "light-year",
symbol = "ly",
utype = "length",
scale = 9.4607304725808e15,
default = "AU",
},
["m"] = {
_name1 = "metre",
_name1_us= "meter",
_symbol = "m",
utype = "length",
scale = 1,
prefixes = 1,
default = "v > 0 and v < 3 ! ftin ! ft",
link = "Metre",
},
["mi"] = {
name1 = "mile",
symbol = "mi",
utype = "length",
scale = 1609.344,
default = "km",
subdivs = { ["ch"] = { 80, default = "km" }, ["chlk"] = { 80, default = "km" }, ["chain"] = { 80, default = "km" }, ["chainlk"] = { 80, default = "km" }, ["ft"] = { 5280, default = "km" }, ["furlong"] = { 8, default = "km" }, ["yd"] = { 1760, default = "km" } },
},
["mil"] = {
symbol = "mil",
usename = 1,
utype = "length",
scale = 0.0000254,
default = "mm",
link = "Thousandth of an inch",
},
["Mly"] = {
name1 = "megalight-year",
symbol = "Mly",
utype = "length",
scale = 9.4607304725808e21,
default = "kpc",
link = "Light-year#Definitions",
},
["Mpc"] = {
name1 = "megaparsec",
symbol = "Mpc",
utype = "length",
scale = 3.0856775814671916e22,
default = "Mly",
link = "Parsec#Megaparsecs and gigaparsecs",
},
["NM"] = {
name1 = "nautical mile",
symbol = "NM",
utype = "length",
scale = 1852,
default = "km mi",
},
["nmi"] = {
name1 = "nautical mile",
symbol = "nmi",
utype = "length",
scale = 1852,
default = "km mi",
},
["oldUKnmi"] = {
name1 = "nautical mile",
symbol = "nmi",
utype = "length",
scale = 1853.184,
default = "km mi",
},
["oldUSnmi"] = {
name1 = "nautical mile",
symbol = "nmi",
utype = "length",
scale = 1853.24496,
default = "km mi",
},
["pc"] = {
name1 = "parsec",
symbol = "pc",
utype = "length",
scale = 3.0856775814671916e16,
default = "ly",
},
["perch"] = {
name2 = "perches",
symbol = "perch",
usename = 1,
utype = "length",
scale = 5.0292,
default = "ft m",
link = "Rod (unit)",
},
["pitch"] = {
name2 = "μm",
symbol = "μm",
utype = "length",
scale = 1e-6,
default = "dpi",
defkey = "pitch",
linkey = "pitch",
link = "Dots per inch",
},
["pole"] = {
symbol = "pole",
usename = 1,
utype = "length",
scale = 5.0292,
default = "ft m",
link = "Rod (unit)",
},
["pre1954U.S.nmi"] = {
name1 = "(pre-1954 U.S.) nautical mile",
symbol = "(pre‑1954 U.S.) nmi",
utype = "length",
scale = 1853.24496,
default = "km mi",
link = "Nautical mile",
},
["pre1954USnmi"] = {
name1 = "(pre-1954 US) nautical mile",
name1_us = "(pre-1954 U.S.) nautical mile",
symbol = "(pre‑1954 US) nmi",
sym_us = "(pre‑1954 U.S.) nmi",
utype = "length",
scale = 1853.24496,
default = "km mi",
link = "Nautical mile",
},
["rd"] = {
name1 = "rod",
symbol = "rd",
utype = "length",
scale = 5.0292,
default = "ft m",
link = "Rod (unit)",
},
["royal cubit"] = {
name1 = "royal cubit",
symbol = "cu",
utype = "length",
scale = 0.524,
default = "mm",
},
["rtkm"] = {
name1 = "route kilometre",
name1_us = "route kilometer",
symbol = "km",
utype = "length",
scale = 1000,
default = "mi",
link = "Kilometre",
},
["rtmi"] = {
name1 = "route mile",
symbol = "mi",
utype = "length",
scale = 1609.344,
default = "km",
link = "Mile",
},
["shaku"] = {
name2 = "shaku",
symbol = "shaku",
usename = 1,
utype = "length",
scale = 0.30303030303030304,
default = "m",
link = "Shaku (unit)",
},
["sm"] = {
name1 = "smoot",
symbol = "sm",
utype = "length",
scale = 1.70180,
default = "m",
link = "Smoot (unit)",
},
["smi"] = {
name1 = "statute mile",
symbol = "mi",
utype = "length",
scale = 1609.344,
default = "km",
subdivs = { ["chain"] = { 80, default = "km" } },
},
["solar radius"] = {
name1 = "solar radius",
name2 = "solar radii",
symbol = "''R''<sub>☉</sub>",
utype = "length",
scale = 695700e3,
default = "km",
},
["sun"] = {
name2 = "sun",
symbol = "sun",
usename = 1,
utype = "length",
scale = 0.030303030303030304,
default = "mm",
link = "Japanese units of measurement#Length",
},
["thou"] = {
name2 = "thou",
symbol = "thou",
usename = 1,
utype = "length",
scale = 0.0000254,
default = "mm",
link = "Thousandth of an inch",
},
["verst"] = {
symbol = "verst",
usename = 1,
utype = "length",
scale = 1066.8,
default = "km mi",
},
["yd"] = {
name1 = "yard",
symbol = "yd",
utype = "length",
scale = 0.9144,
default = "m",
subdivs = { ["ft"] = { 3, default = "m" } },
},
["μin"] = {
name1 = "microinch",
name2 = "microinches",
symbol = "μin",
utype = "length",
scale = 0.0000000254,
default = "nm",
link = "SI prefix#Non-metric units",
},
["Å"] = {
name1 = "ångström",
symbol = "Å",
utype = "length",
scale = 0.0000000001,
default = "in",
},
["Hz"] = {
_name1 = "hertz",
_name2 = "hertz",
_symbol = "Hz",
utype = "length",
scale = 3.3356409519815204e-9,
invert = -1,
iscomplex= true,
prefixes = 1,
default = "m",
link = "Hertz",
},
["rpm"] = {
name1 = "revolution per minute",
name2 = "revolutions per minute",
symbol = "rpm",
utype = "length",
scale = 5.5594015866358675e-11,
invert = -1,
iscomplex= true,
default = "Hz",
link = "Revolutions per minute",
},
["-ft-frac"] = {
target = "ft",
link = "Fracture gradient",
},
["-in-stiff"] = {
target = "in",
link = "Stiffness",
},
["-m-frac"] = {
target = "m",
link = "Fracture gradient",
},
["-m-stiff"] = {
target = "m",
link = "Stiffness",
},
["100km"] = {
target = "km",
multiplier= 100,
},
["100mi"] = {
target = "mi",
multiplier= 100,
},
["100miles"] = {
target = "mi",
symbol = "miles",
multiplier= 100,
},
["admiralty nmi"] = {
target = "oldUKnmi",
},
["angstrom"] = {
target = "Å",
},
["au"] = {
target = "AU",
symbol = "au",
},
["feet"] = {
target = "ft",
},
["hands"] = {
target = "hand",
},
["inch"] = {
target = "in",
},
["inches"] = {
target = "in",
},
["light-year"] = {
target = "ly",
},
["meter"] = {
target = "m",
sp_us = true,
},
["meters"] = {
target = "m",
sp_us = true,
},
["metre"] = {
target = "m",
},
["metres"] = {
target = "m",
},
["micrometre"] = {
target = "μm",
},
["micron"] = {
target = "μm",
default = "μin",
},
["mile"] = {
target = "mi",
},
["miles"] = {
target = "mi",
},
["parsec"] = {
target = "pc",
},
["rod"] = {
target = "rd",
},
["smoot"] = {
target = "sm",
},
["uin"] = {
target = "μin",
},
["yard"] = {
target = "yd",
},
["yards"] = {
target = "yd",
},
["yds"] = {
target = "yd",
},
["dtex"] = {
name1 = "decitex",
name2 = "decitex",
symbol = "dtex",
utype = "linear density",
scale = 1e-7,
default = "lb/yd",
link = "Units of textile measurement#Units",
},
["kg/cm"] = {
name1 = "kilogram per centimetre",
name1_us = "kilogram per centimeter",
name2 = "kilograms per centimetre",
name2_us = "kilograms per centimeter",
symbol = "kg/cm",
utype = "linear density",
scale = 100,
default = "lb/yd",
link = "Linear density",
},
["kg/m"] = {
name1 = "kilogram per metre",
name1_us = "kilogram per meter",
name2 = "kilograms per metre",
name2_us = "kilograms per meter",
symbol = "kg/m",
utype = "linear density",
scale = 1,
default = "lb/yd",
link = "Linear density",
},
["lb/ft"] = {
name1 = "pound per foot",
name2 = "pounds per foot",
symbol = "lb/ft",
utype = "linear density",
scale = 1.4881639435695539,
default = "kg/m",
link = "Linear density",
},
["lb/yd"] = {
name1 = "pound per yard",
name2 = "pounds per yard",
symbol = "lb/yd",
utype = "linear density",
scale = 0.49605464785651798,
default = "kg/m",
link = "Linear density",
},
["G"] = {
_name1 = "gauss",
_name2 = "gauss",
_symbol = "G",
utype = "magnetic field strength",
scale = 0.0001,
prefixes = 1,
default = "T",
link = "Gauss (unit)",
},
["T"] = {
_name1 = "tesla",
_symbol = "T",
utype = "magnetic field strength",
scale = 1,
prefixes = 1,
default = "G",
link = "Tesla (unit)",
},
["A/m"] = {
name1 = "ampere per metre",
name1_us = "ampere per meter",
name2 = "amperes per metre",
name2_us = "amperes per meter",
symbol = "A/m",
utype = "magnetizing field",
scale = 1,
default = "Oe",
},
["kA/m"] = {
name1 = "kiloampere per metre",
name1_us = "kiloampere per meter",
name2 = "kiloamperes per metre",
name2_us = "kiloamperes per meter",
symbol = "kA/m",
utype = "magnetizing field",
scale = 1000,
default = "kOe",
link = "Ampere per metre",
},
["MA/m"] = {
name1 = "megaampere per metre",
name1_us = "megaampere per meter",
name2 = "megaamperes per metre",
name2_us = "megaamperes per meter",
symbol = "MA/m",
utype = "magnetizing field",
scale = 1e6,
default = "kOe",
link = "Ampere per metre",
},
["Oe"] = {
_name1 = "oersted",
_symbol = "Oe",
utype = "magnetizing field",
scale = 79.5774715,
prefixes = 1,
default = "kA/m",
link = "Oersted",
},
["-Lcwt"] = {
name1 = "hundredweight",
name2 = "hundredweight",
symbol = "cwt",
utype = "mass",
scale = 50.80234544,
default = "lb",
},
["-Scwt"] = {
name1 = "hundredweight",
name2 = "hundredweight",
symbol = "cwt",
utype = "mass",
scale = 45.359237,
default = "lb",
},
["-ST"] = {
name1 = "short ton",
symbol = "ST",
utype = "mass",
scale = 907.18474,
default = "t",
},
["carat"] = {
symbol = "carat",
usename = 1,
utype = "mass",
scale = 0.0002,
default = "g",
link = "Carat (mass)",
},
["drachm"] = {
name1_us = "dram",
symbol = "drachm",
usename = 1,
utype = "mass",
scale = 0.001771845195,
default = "g",
link = "Dram (unit)",
},
["dram"] = {
target = "drachm",
},
["dwt"] = {
name1 = "pennyweight",
symbol = "dwt",
utype = "mass",
scale = 0.00155517384,
default = "oz g",
},
["DWton"] = {
symbol = "deadweight ton",
usename = 1,
utype = "mass",
scale = 1016.0469088,
default = "DWtonne",
link = "Deadweight tonnage",
},
["DWtonne"] = {
name1_us = "deadweight metric ton",
symbol = "deadweight tonne",
sym_us = "~deadweight metric ton",
usename = 1,
utype = "mass",
scale = 1000,
default = "DWton",
link = "Deadweight tonnage",
},
["g"] = {
_name1 = "gram",
_symbol = "g",
utype = "mass",
scale = 0.001,
prefixes = 1,
default = "oz",
link = "Gram",
},
["gr"] = {
name1 = "grain",
symbol = "gr",
utype = "mass",
scale = 0.00006479891,
default = "g",
link = "Grain (unit)",
},
["Gt"] = {
name1 = "gigatonne",
symbol = "Gt",
utype = "mass",
scale = 1000000000000,
default = "LT ST",
link = "Tonne",
},
["impgalh2o"] = {
name1 = "imperial gallon of water",
name2 = "imperial gallons of water",
symbol = "imp gal H<sub>2</sub>O",
utype = "mass",
scale = 4.5359236999999499,
default = "lb kg",
link = "Imperial gallon",
},
["kt"] = {
name1 = "kilotonne",
symbol = "kt",
utype = "mass",
scale = 1000000,
default = "LT ST",
link = "Tonne",
},
["lb"] = {
name1 = "pound",
symbol = "lb",
utype = "mass",
scale = 0.45359237,
exception= "integer_more_precision",
default = "kg",
subdivs = { ["oz"] = { 16, default = "kg" } },
link = "Pound (mass)",
},
["Lcwt"] = {
name1 = "long hundredweight",
name2 = "long hundredweight",
symbol = "Lcwt",
usename = 1,
utype = "mass",
scale = 50.80234544,
default = "lb",
subdivs = { ["qtr"] = { 4, default = "kg" }, ["st"] = { 8, default = "kg" } },
link = "Hundredweight",
},
["long cwt"] = {
name1 = "long hundredweight",
name2 = "long hundredweight",
symbol = "long cwt",
utype = "mass",
scale = 50.80234544,
default = "lb kg",
subdivs = { ["qtr"] = { 4, default = "kg" } },
link = "Hundredweight",
},
["long qtr"] = {
name1 = "long quarter",
symbol = "long qtr",
utype = "mass",
scale = 12.70058636,
default = "lb kg",
},
["LT"] = {
symbol = "long ton",
usename = 1,
utype = "mass",
scale = 1016.0469088,
default = "t",
subdivs = { ["Lcwt"] = { 20, default = "t", unit = "-Lcwt" } },
},
["lt"] = {
name1 = "long ton",
symbol = "LT",
utype = "mass",
scale = 1016.0469088,
default = "t",
subdivs = { ["Lcwt"] = { 20, default = "t", unit = "-Lcwt" } },
},
["metric ton"] = {
symbol = "metric ton",
usename = 1,
utype = "mass",
scale = 1000,
default = "long ton",
link = "Tonne",
},
["MT"] = {
name1 = "metric ton",
symbol = "t",
utype = "mass",
scale = 1000,
default = "LT ST",
link = "Tonne",
},
["Mt"] = {
name1 = "megatonne",
symbol = "Mt",
utype = "mass",
scale = 1000000000,
default = "LT ST",
link = "Tonne",
},
["oz"] = {
name1 = "ounce",
symbol = "oz",
utype = "mass",
scale = 0.028349523125,
default = "g",
},
["ozt"] = {
name1 = "troy ounce",
symbol = "ozt",
utype = "mass",
scale = 0.0311034768,
default = "oz g",
},
["pdr"] = {
name1 = "pounder",
symbol = "pdr",
utype = "mass",
scale = 0.45359237,
default = "kg",
link = "Pound (mass)",
},
["qtr"] = {
name1 = "quarter",
symbol = "qtr",
utype = "mass",
scale = 12.70058636,
default = "lb kg",
subdivs = { ["lb"] = { 28, default = "kg" } },
link = "Long quarter",
},
["Scwt"] = {
name1 = "short hundredweight",
name2 = "short hundredweight",
symbol = "Scwt",
usename = 1,
utype = "mass",
scale = 45.359237,
default = "lb",
link = "Hundredweight",
},
["short cwt"] = {
name1 = "short hundredweight",
name2 = "short hundredweight",
symbol = "short cwt",
utype = "mass",
scale = 45.359237,
default = "lb kg",
link = "Hundredweight",
},
["short qtr"] = {
name1 = "short quarter",
symbol = "short qtr",
utype = "mass",
scale = 11.33980925,
default = "lb kg",
},
["ST"] = {
symbol = "short ton",
usename = 1,
utype = "mass",
scale = 907.18474,
default = "t",
subdivs = { ["Scwt"] = { 20, default = "t", unit = "-Scwt" } },
},
["shtn"] = {
name1 = "short ton",
symbol = "sh tn",
utype = "mass",
scale = 907.18474,
default = "t",
},
["shton"] = {
symbol = "ton",
usename = 1,
utype = "mass",
scale = 907.18474,
default = "t",
},
["solar mass"] = {
name1 = "solar mass",
name2 = "solar masses",
symbol = "''M''<sub>☉</sub>",
utype = "mass",
scale = 1.98855e30,
default = "kg",
},
["st"] = {
name1 = "stone",
name2 = "stone",
symbol = "st",
utype = "mass",
scale = 6.35029318,
default = "lb kg",
subdivs = { ["lb"] = { 14, default = "kg lb" } },
link = "Stone (unit)",
},
["t"] = {
name1 = "tonne",
name1_us = "metric ton",
symbol = "t",
utype = "mass",
scale = 1000,
default = "LT ST",
},
["tonne"] = {
name1 = "tonne",
name1_us = "metric ton",
symbol = "t",
utype = "mass",
scale = 1000,
default = "shton",
},
["troy pound"] = {
symbol = "troy pound",
usename = 1,
utype = "mass",
scale = 0.3732417216,
default = "lb kg",
link = "Troy weight",
},
["usgalh2o"] = {
name1 = "US gallon of water",
name1_us = "U.S. gallon of water",
name2 = "US gallons of water",
name2_us = "U.S. gallons of water",
symbol = "US gal H<sub>2</sub>O",
utype = "mass",
scale = 3.7776215836051126,
default = "lb kg",
link = "United States customary units#Fluid volume",
},
["viss"] = {
name2 = "viss",
symbol = "viss",
utype = "mass",
scale = 1.632932532,
default = "kg",
link = "Myanmar units of measurement#Mass",
},
["billion tonne"] = {
target = "e9t",
},
["kilogram"] = {
target = "kg",
},
["kilotonne"] = {
target = "kt",
},
["lbs"] = {
target = "lb",
},
["lbt"] = {
target = "troy pound",
},
["lcwt"] = {
target = "Lcwt",
},
["long ton"] = {
target = "LT",
},
["mcg"] = {
target = "μg",
},
["million tonne"] = {
target = "e6t",
},
["scwt"] = {
target = "Scwt",
},
["short ton"] = {
target = "ST",
},
["stone"] = {
target = "st",
},
["thousand tonne"] = {
target = "e3t",
},
["tonnes"] = {
target = "t",
},
["kg/kW"] = {
name1 = "kilogram per kilowatt",
name2 = "kilograms per kilowatt",
symbol = "kg/kW",
utype = "mass per unit power",
scale = 0.001,
default = "lb/hp",
link = "Kilowatt",
},
["lb/hp"] = {
name1 = "pound per horsepower",
name2 = "pounds per horsepower",
symbol = "lb/hp",
utype = "mass per unit power",
scale = 0.00060827738784176115,
default = "kg/kW",
link = "Horsepower",
},
["kg/h"] = {
per = { "kg", "h" },
utype = "mass per unit time",
default = "lb/h",
},
["lb/h"] = {
per = { "lb", "h" },
utype = "mass per unit time",
default = "kg/h",
},
["g-mol/d"] = {
name1 = "gram-mole per day",
name2 = "gram-moles per day",
symbol = "g‑mol/d",
utype = "molar rate",
scale = 1.1574074074074073e-5,
default = "μmol/s",
link = "Mole (unit)",
},
["g-mol/h"] = {
name1 = "gram-mole per hour",
name2 = "gram-moles per hour",
symbol = "g‑mol/h",
utype = "molar rate",
scale = 0.00027777777777777778,
default = "mmol/s",
link = "Mole (unit)",
},
["g-mol/min"] = {
name1 = "gram-mole per minute",
name2 = "gram-moles per minute",
symbol = "g‑mol/min",
utype = "molar rate",
scale = 0.016666666666666666,
default = "g-mol/s",
link = "Mole (unit)",
},
["g-mol/s"] = {
name1 = "gram-mole per second",
name2 = "gram-moles per second",
symbol = "g‑mol/s",
utype = "molar rate",
scale = 1,
default = "lb-mol/min",
link = "Mole (unit)",
},
["gmol/d"] = {
name1 = "gram-mole per day",
name2 = "gram-moles per day",
symbol = "gmol/d",
utype = "molar rate",
scale = 1.1574074074074073e-5,
default = "μmol/s",
link = "Mole (unit)",
},
["gmol/h"] = {
name1 = "gram-mole per hour",
name2 = "gram-moles per hour",
symbol = "gmol/h",
utype = "molar rate",
scale = 0.00027777777777777778,
default = "mmol/s",
link = "Mole (unit)",
},
["gmol/min"] = {
name1 = "gram-mole per minute",
name2 = "gram-moles per minute",
symbol = "gmol/min",
utype = "molar rate",
scale = 0.016666666666666666,
default = "gmol/s",
link = "Mole (unit)",
},
["gmol/s"] = {
name1 = "gram-mole per second",
name2 = "gram-moles per second",
symbol = "gmol/s",
utype = "molar rate",
scale = 1,
default = "lbmol/min",
link = "Mole (unit)",
},
["kmol/d"] = {
name1 = "kilomole per day",
name2 = "kilomoles per day",
symbol = "kmol/d",
utype = "molar rate",
scale = 0.011574074074074073,
default = "mmol/s",
link = "Mole (unit)",
},
["kmol/h"] = {
name1 = "kilomole per hour",
name2 = "kilomoles per hour",
symbol = "kmol/h",
utype = "molar rate",
scale = 0.27777777777777779,
default = "mol/s",
link = "Mole (unit)",
},
["kmol/min"] = {
name1 = "kilomole per minute",
name2 = "kilomoles per minute",
symbol = "kmol/min",
utype = "molar rate",
scale = 16.666666666666668,
default = "mol/s",
link = "Kilomole (unit)",
},
["kmol/s"] = {
name1 = "kilomole per second",
name2 = "kilomoles per second",
symbol = "kmol/s",
utype = "molar rate",
scale = 1000,
default = "lb-mol/s",
link = "Mole (unit)",
},
["lb-mol/d"] = {
name1 = "pound-mole per day",
name2 = "pound-moles per day",
symbol = "lb‑mol/d",
utype = "molar rate",
scale = 0.0052499116898148141,
default = "mmol/s",
link = "Pound-mole",
},
["lb-mol/h"] = {
name1 = "pound-mole per hour",
name2 = "pound-moles per hour",
symbol = "lb‑mol/h",
utype = "molar rate",
scale = 0.12599788055555555,
default = "mol/s",
link = "Pound-mole",
},
["lb-mol/min"] = {
name1 = "pound-mole per minute",
name2 = "pound-moles per minute",
symbol = "lb‑mol/min",
utype = "molar rate",
scale = 7.5598728333333334,
default = "mol/s",
link = "Pound-mole",
},
["lb-mol/s"] = {
name1 = "pound-mole per second",
name2 = "pound-moles per second",
symbol = "lb‑mol/s",
utype = "molar rate",
scale = 453.59237,
default = "kmol/s",
link = "Pound-mole",
},
["lbmol/d"] = {
name1 = "pound-mole per day",
name2 = "pound-moles per day",
symbol = "lbmol/d",
utype = "molar rate",
scale = 0.0052499116898148141,
default = "mmol/s",
link = "Pound-mole",
},
["lbmol/h"] = {
name1 = "pound-mole per hour",
name2 = "pound-moles per hour",
symbol = "lbmol/h",
utype = "molar rate",
scale = 0.12599788055555555,
default = "mol/s",
link = "Pound-mole",
},
["lbmol/min"] = {
name1 = "pound-mole per minute",
name2 = "pound-moles per minute",
symbol = "lbmol/min",
utype = "molar rate",
scale = 7.5598728333333334,
default = "mol/s",
link = "Pound-mole",
},
["lbmol/s"] = {
name1 = "pound-mole per second",
name2 = "pound-moles per second",
symbol = "lbmol/s",
utype = "molar rate",
scale = 453.59237,
default = "kmol/s",
link = "Pound-mole",
},
["mmol/s"] = {
name1 = "millimole per second",
name2 = "millimoles per second",
symbol = "mmol/s",
utype = "molar rate",
scale = 0.001,
default = "lb-mol/d",
link = "Mole (unit)",
},
["mol/d"] = {
name1 = "mole per day",
name2 = "moles per day",
symbol = "mol/d",
utype = "molar rate",
scale = 1.1574074074074073e-5,
default = "μmol/s",
link = "Mole (unit)",
},
["mol/h"] = {
name1 = "mole per hour",
name2 = "moles per hour",
symbol = "mol/h",
utype = "molar rate",
scale = 0.00027777777777777778,
default = "mmol/s",
link = "Mole (unit)",
},
["mol/min"] = {
name1 = "mole per minute",
name2 = "moles per minute",
symbol = "mol/min",
utype = "molar rate",
scale = 0.016666666666666666,
default = "mol/s",
link = "Mole (unit)",
},
["mol/s"] = {
name1 = "mole per second",
name2 = "moles per second",
symbol = "mol/s",
utype = "molar rate",
scale = 1,
default = "lb-mol/min",
link = "Mole (unit)",
},
["μmol/s"] = {
name1 = "micromole per second",
name2 = "micromoles per second",
symbol = "μmol/s",
utype = "molar rate",
scale = 0.000001,
default = "lb-mol/d",
link = "Mole (unit)",
},
["umol/s"] = {
target = "μmol/s",
},
["/acre"] = {
name1 = "per acre",
name2 = "per acre",
symbol = "/acre",
utype = "per unit area",
scale = 0.00024710538146716532,
default = "/ha",
link = "Acre",
},
["/ha"] = {
name1 = "per hectare",
name2 = "per hectare",
symbol = "/ha",
utype = "per unit area",
scale = 100e-6,
default = "/acre",
link = "Hectare",
},
["/sqcm"] = {
name1 = "per square centimetre",
name1_us = "per square centimeter",
name2 = "per square centimetre",
name2_us = "per square centimeter",
symbol = "/cm<sup>2</sup>",
utype = "per unit area",
scale = 1e4,
default = "/sqin",
link = "Square centimetre",
},
["/sqin"] = {
name1 = "per square inch",
name2 = "per square inch",
symbol = "/in<sup>2</sup>",
utype = "per unit area",
scale = 1550.0031000062002,
default = "/sqcm",
link = "Square inch",
},
["/sqkm"] = {
name1 = "per square kilometre",
name1_us = "per square kilometer",
name2 = "per square kilometre",
name2_us = "per square kilometer",
symbol = "/km<sup>2</sup>",
utype = "per unit area",
scale = 1e-6,
default = "/sqmi",
link = "Square kilometre",
},
["/sqmi"] = {
name1 = "per square mile",
name2 = "per square mile",
symbol = "/sq mi",
utype = "per unit area",
scale = 3.8610215854244582e-7,
default = "/sqkm",
link = "Square mile",
},
["PD/acre"] = {
name1 = "inhabitant per acre",
name2 = "inhabitants per acre",
symbol = "/acre",
utype = "per unit area",
scale = 0.00024710538146716532,
default = "PD/ha",
link = "Acre",
},
["PD/ha"] = {
name1 = "inhabitant per hectare",
name2 = "inhabitants per hectare",
symbol = "/ha",
utype = "per unit area",
scale = 100e-6,
default = "PD/acre",
link = "Hectare",
},
["PD/sqkm"] = {
name1 = "inhabitant per square kilometre",
name1_us = "inhabitant per square kilometer",
name2 = "inhabitants per square kilometre",
name2_us = "inhabitants per square kilometer",
symbol = "/km<sup>2</sup>",
utype = "per unit area",
scale = 1e-6,
default = "PD/sqmi",
link = "Square kilometre",
},
["PD/sqmi"] = {
name1 = "inhabitant per square mile",
name2 = "inhabitants per square mile",
symbol = "/sq mi",
utype = "per unit area",
scale = 3.8610215854244582e-7,
default = "PD/sqkm",
link = "Square mile",
},
["/cm2"] = {
target = "/sqcm",
},
["/in2"] = {
target = "/sqin",
},
["/km2"] = {
target = "/sqkm",
},
["pd/acre"] = {
target = "PD/acre",
},
["pd/ha"] = {
target = "PD/ha",
},
["PD/km2"] = {
target = "PD/sqkm",
},
["pd/km2"] = {
target = "PD/sqkm",
},
["PD/km²"] = {
target = "PD/sqkm",
},
["pd/sqkm"] = {
target = "PD/sqkm",
},
["pd/sqmi"] = {
target = "PD/sqmi",
},
["/l"] = {
name1 = "per litre",
name1_us = "per liter",
name2 = "per litre",
name2_us = "per liter",
symbol = "/l",
utype = "per unit volume",
scale = 1000,
default = "/usgal",
link = "Litre",
},
["/L"] = {
name1 = "per litre",
name1_us = "per liter",
name2 = "per litre",
name2_us = "per liter",
symbol = "/L",
utype = "per unit volume",
scale = 1000,
default = "/usgal",
link = "Litre",
},
["/USgal"] = {
name1 = "per gallon",
name2 = "per gallon",
symbol = "/gal",
utype = "per unit volume",
scale = 264.172052,
default = "/L",
link = "US gallon",
customary= 2,
},
["/usgal"] = {
target = "/USgal",
},
["bhp"] = {
name1 = "brake horsepower",
name2 = "brake horsepower",
symbol = "bhp",
utype = "power",
scale = 745.69987158227022,
default = "kW",
link = "Horsepower#Brake horsepower",
},
["Cal/d"] = {
name1 = "large calorie per day",
name2 = "large calories per day",
symbol = "Cal/d",
utype = "power",
scale = 0.048425925925925928,
default = "kJ/d",
link = "Calorie",
},
["Cal/h"] = {
name1 = "large calorie per hour",
name2 = "large calories per hour",
symbol = "Cal/h",
utype = "power",
scale = 1.1622222222222223,
default = "kJ/h",
link = "Calorie",
},
["cal/h"] = {
name1 = "calorie per hour",
name2 = "calories per hour",
symbol = "cal/h",
utype = "power",
scale = 0.0011622222222222223,
default = "W",
link = "Calorie",
},
["CV"] = {
name1 = "metric horsepower",
name2 = "metric horsepower",
symbol = "CV",
utype = "power",
scale = 735.49875,
default = "kW",
},
["hk"] = {
name1 = "metric horsepower",
name2 = "metric horsepower",
symbol = "hk",
utype = "power",
scale = 735.49875,
default = "kW",
},
["hp"] = {
name1 = "horsepower",
name2 = "horsepower",
symbol = "hp",
utype = "power",
scale = 745.69987158227022,
default = "kW",
},
["hp-electric"] = {
name1 = "electric horsepower",
name2 = "electric horsepower",
symbol = "hp",
utype = "power",
scale = 746,
default = "kW",
link = "Horsepower#Electrical horsepower",
},
["hp-electrical"] = {
name1 = "electrical horsepower",
name2 = "electrical horsepower",
symbol = "hp",
utype = "power",
scale = 746,
default = "kW",
link = "Horsepower#Electrical horsepower",
},
["hp-metric"] = {
name1 = "metric horsepower",
name2 = "metric horsepower",
symbol = "hp",
utype = "power",
scale = 735.49875,
default = "kW",
},
["ihp"] = {
name1 = "indicated horsepower",
name2 = "indicated horsepower",
symbol = "ihp",
utype = "power",
scale = 745.69987158227022,
default = "kW",
link = "Horsepower#Indicated horsepower",
},
["kcal/h"] = {
name1 = "kilocalorie per hour",
name2 = "kilocalories per hour",
symbol = "kcal/h",
utype = "power",
scale = 1.1622222222222223,
default = "kW",
link = "Calorie",
},
["kJ/d"] = {
name1 = "kilojoule per day",
name2 = "kilojoules per day",
symbol = "kJ/d",
utype = "power",
scale = 0.011574074074074073,
default = "Cal/d",
link = "Kilojoule",
},
["kJ/h"] = {
name1 = "kilojoule per hour",
name2 = "kilojoules per hour",
symbol = "kJ/h",
utype = "power",
scale = 0.27777777777777779,
default = "W",
link = "Kilojoule",
},
["PS"] = {
name1 = "metric horsepower",
name2 = "metric horsepower",
symbol = "PS",
utype = "power",
scale = 735.49875,
default = "kW",
},
["shp"] = {
name1 = "shaft horsepower",
name2 = "shaft horsepower",
symbol = "shp",
utype = "power",
scale = 745.69987158227022,
default = "kW",
link = "Horsepower#Shaft horsepower",
},
["W"] = {
_name1 = "watt",
_symbol = "W",
utype = "power",
scale = 1,
prefixes = 1,
default = "hp",
link = "Watt",
},
["BTU/h"] = {
per = { "BTU", "h" },
utype = "power",
default = "W",
},
["Btu/h"] = {
per = { "Btu", "h" },
utype = "power",
default = "W",
},
["BHP"] = {
target = "bhp",
},
["btu/h"] = {
target = "BTU/h",
},
["HP"] = {
target = "hp",
},
["Hp"] = {
target = "hp",
},
["hp-mechanical"] = {
target = "hp",
},
["IHP"] = {
target = "ihp",
},
["SHP"] = {
target = "shp",
},
["whp"] = {
target = "hp",
},
["hp/lb"] = {
name1 = "horsepower per pound",
name2 = "horsepower per pound",
symbol = "hp/lb",
utype = "power per unit mass",
scale = 1643.986806,
default = "kW/kg",
link = "Power-to-weight ratio",
},
["hp/LT"] = {
name1 = "horsepower per long ton",
name2 = "horsepower per long ton",
symbol = "hp/LT",
utype = "power per unit mass",
scale = 0.73392268125000004,
default = "kW/t",
link = "Power-to-weight ratio",
},
["hp/ST"] = {
name1 = "horsepower per short ton",
name2 = "horsepower per short ton",
symbol = "hp/ST",
utype = "power per unit mass",
scale = 0.821993403,
default = "kW/t",
link = "Power-to-weight ratio",
},
["hp/t"] = {
name1 = "horsepower per tonne",
name2 = "horsepower per tonne",
symbol = "hp/t",
utype = "power per unit mass",
scale = 0.74569987158227022,
default = "kW/t",
link = "Power-to-weight ratio",
},
["kW/kg"] = {
name1 = "kilowatt per kilogram",
name2 = "kilowatts per kilogram",
symbol = "kW/kg",
utype = "power per unit mass",
scale = 1000,
default = "hp/lb",
link = "Power-to-weight ratio",
},
["kW/t"] = {
name1 = "kilowatt per tonne",
name2 = "kilowatts per tonne",
symbol = "kW/t",
utype = "power per unit mass",
scale = 1,
default = "PS/t",
link = "Power-to-weight ratio",
},
["PS/t"] = {
name1 = "metric horsepower per tonne",
name2 = "metric horsepower per tonne",
symbol = "PS/t",
utype = "power per unit mass",
scale = 0.73549875,
default = "kW/t",
link = "Power-to-weight ratio",
},
["shp/lb"] = {
name1 = "shaft horsepower per pound",
name2 = "shaft horsepower per pound",
symbol = "shp/lb",
utype = "power per unit mass",
scale = 1643.986806,
default = "kW/kg",
link = "Power-to-weight ratio",
},
["hp/tonne"] = {
target = "hp/t",
symbol = "hp/tonne",
default = "kW/tonne",
},
["kW/tonne"] = {
target = "kW/t",
symbol = "kW/tonne",
},
["-lb/in2"] = {
name1 = "pound per square inch",
name2 = "pounds per square inch",
symbol = "lb/in<sup>2</sup>",
utype = "pressure",
scale = 6894.7572931683608,
default = "kPa kgf/cm2",
},
["atm"] = {
name1 = "standard atmosphere",
symbol = "atm",
utype = "pressure",
scale = 101325,
default = "kPa",
link = "Atmosphere (unit)",
},
["Ba"] = {
name1 = "barye",
symbol = "Ba",
utype = "pressure",
scale = 0.1,
default = "Pa",
},
["bar"] = {
symbol = "bar",
utype = "pressure",
scale = 100000,
default = "kPa",
link = "Bar (unit)",
},
["dbar"] = {
name1 = "decibar",
symbol = "dbar",
utype = "pressure",
scale = 10000,
default = "kPa",
link = "Bar (unit)",
},
["inHg"] = {
name1 = "inch of mercury",
name2 = "inches of mercury",
symbol = "inHg",
utype = "pressure",
scale = 3386.388640341,
default = "kPa",
},
["kBa"] = {
name1 = "kilobarye",
symbol = "kBa",
utype = "pressure",
scale = 100,
default = "hPa",
link = "Barye",
},
["kg-f/cm2"] = {
name1 = "kilogram-force per square centimetre",
name1_us = "kilogram-force per square centimeter",
name2 = "kilograms-force per square centimetre",
name2_us = "kilograms-force per square centimeter",
symbol = "kg<sub>f</sub>/cm<sup>2</sup>",
utype = "pressure",
scale = 98066.5,
default = "psi",
link = "Kilogram-force",
},
["kg/cm2"] = {
name1 = "kilogram per square centimetre",
name1_us = "kilogram per square centimeter",
name2 = "kilograms per square centimetre",
name2_us = "kilograms per square centimeter",
symbol = "kg/cm<sup>2</sup>",
utype = "pressure",
scale = 98066.5,
default = "psi",
link = "Kilogram-force",
},
["kgf/cm2"] = {
name1 = "kilogram-force per square centimetre",
name1_us = "kilogram-force per square centimeter",
name2 = "kilograms-force per square centimetre",
name2_us = "kilograms-force per square centimeter",
symbol = "kgf/cm<sup>2</sup>",
utype = "pressure",
scale = 98066.5,
default = "psi",
link = "Kilogram-force",
},
["ksi"] = {
name1 = "kilopound per square inch",
name2 = "kilopounds per square inch",
symbol = "ksi",
utype = "pressure",
scale = 6894757.2931683613,
default = "MPa",
link = "Pound per square inch",
},
["lbf/in2"] = {
name1 = "pound-force per square inch",
name2 = "pounds-force per square inch",
symbol = "lbf/in<sup>2</sup>",
utype = "pressure",
scale = 6894.7572931683608,
default = "kPa kgf/cm2",
},
["mb"] = {
name1 = "millibar",
symbol = "mb",
utype = "pressure",
scale = 100,
default = "hPa",
link = "Bar (unit)",
},
["mbar"] = {
name1 = "millibar",
symbol = "mbar",
utype = "pressure",
scale = 100,
default = "hPa",
link = "Bar (unit)",
},
["mmHg"] = {
name1 = "millimetre of mercury",
name1_us = "millimeter of mercury",
name2 = "millimetres of mercury",
name2_us = "millimeters of mercury",
symbol = "mmHg",
utype = "pressure",
scale = 133.322387415,
default = "kPa",
},
["Pa"] = {
_name1 = "pascal",
_symbol = "Pa",
utype = "pressure",
scale = 1,
prefixes = 1,
default = "psi",
link = "Pascal (unit)",
},
["psf"] = {
name1 = "pound per square foot",
name2 = "pounds per square foot",
symbol = "psf",
utype = "pressure",
scale = 47.880258980335839,
default = "kPa",
link = "Pound per square inch",
},
["psi"] = {
name1 = "pound per square inch",
name2 = "pounds per square inch",
symbol = "psi",
utype = "pressure",
scale = 6894.7572931683608,
default = "kPa",
},
["Torr"] = {
name1 = "torr",
symbol = "Torr",
utype = "pressure",
scale = 133.32236842105263,
default = "kPa",
},
["N/cm2"] = {
per = { "N", "cm2" },
utype = "pressure",
default = "psi",
},
["N/m2"] = {
per = { "N", "m2" },
utype = "pressure",
default = "psi",
},
["g/cm2"] = {
per = { "g", "cm2" },
utype = "pressure",
default = "lb/sqft",
multiplier= 9.80665,
},
["g/m2"] = {
per = { "g", "m2" },
utype = "pressure",
default = "lb/sqft",
multiplier= 9.80665,
},
["kg/ha"] = {
per = { "kg", "ha" },
utype = "pressure",
default = "lb/acre",
multiplier= 9.80665,
},
["kg/m2"] = {
per = { "kg", "m2" },
utype = "pressure",
default = "lb/sqft",
multiplier= 9.80665,
},
["lb/1000sqft"] = {
per = { "lb", "1000sqft" },
utype = "pressure",
default = "g/m2",
multiplier= 9.80665,
},
["lb/acre"] = {
per = { "lb", "acre" },
utype = "pressure",
default = "kg/ha",
multiplier= 9.80665,
},
["lb/sqft"] = {
per = { "lb", "sqft" },
utype = "pressure",
default = "kg/m2",
multiplier= 9.80665,
},
["lb/sqyd"] = {
per = { "lb", "sqyd" },
utype = "pressure",
default = "kg/m2",
multiplier= 9.80665,
},
["LT/acre"] = {
per = { "LT", "acre" },
utype = "pressure",
default = "t/ha",
multiplier= 9.80665,
},
["MT/ha"] = {
per = { "MT", "ha" },
utype = "pressure",
default = "LT/acre ST/acre",
multiplier= 9.80665,
},
["oz/sqft"] = {
per = { "oz", "sqft" },
utype = "pressure",
default = "g/m2",
multiplier= 9.80665,
},
["oz/sqyd"] = {
per = { "oz", "sqyd" },
utype = "pressure",
default = "g/m2",
multiplier= 9.80665,
},
["ST/acre"] = {
per = { "ST", "acre" },
utype = "pressure",
default = "t/ha",
multiplier= 9.80665,
},
["t/ha"] = {
per = { "t", "ha" },
utype = "pressure",
default = "LT/acre ST/acre",
multiplier= 9.80665,
},
["tonne/acre"] = {
per = { "tonne", "acre" },
utype = "pressure",
default = "tonne/ha",
multiplier= 9.80665,
},
["tonne/ha"] = {
per = { "tonne", "ha" },
utype = "pressure",
default = "tonne/acre",
multiplier= 9.80665,
},
["kgfpsqcm"] = {
target = "kgf/cm2",
},
["kgpsqcm"] = {
target = "kg/cm2",
},
["kN/m2"] = {
target = "kPa",
},
["lb/in2"] = {
target = "lbf/in2",
},
["torr"] = {
target = "Torr",
},
["Bq"] = {
_name1 = "becquerel",
_symbol = "Bq",
utype = "radioactivity",
scale = 1,
prefixes = 1,
default = "pCi",
link = "Becquerel",
},
["Ci"] = {
_name1 = "curie",
_symbol = "Ci",
utype = "radioactivity",
scale = 3.7e10,
prefixes = 1,
default = "GBq",
link = "Curie (unit)",
},
["Rd"] = {
_name1 = "rutherford",
_symbol = "Rd",
utype = "radioactivity",
scale = 1e6,
prefixes = 1,
default = "MBq",
link = "Rutherford (unit)",
},
["cm/h"] = {
name1 = "centimetre per hour",
name1_us = "centimeter per hour",
name2 = "centimetres per hour",
name2_us = "centimeters per hour",
symbol = "cm/h",
utype = "speed",
scale = 2.7777777777777775e-6,
default = "in/h",
link = "Metre per second",
},
["cm/s"] = {
name1 = "centimetre per second",
name1_us = "centimeter per second",
name2 = "centimetres per second",
name2_us = "centimeters per second",
symbol = "cm/s",
utype = "speed",
scale = 0.01,
default = "in/s",
link = "Metre per second",
},
["cm/year"] = {
name1 = "centimetre per year",
name1_us = "centimeter per year",
name2 = "centimetres per year",
name2_us = "centimeters per year",
symbol = "cm/year",
utype = "speed",
scale = 3.168873850681143e-10,
default = "in/year",
link = "Orders of magnitude (speed)",
},
["foot/s"] = {
name1 = "foot per second",
name2 = "foot per second",
symbol = "ft/s",
utype = "speed",
scale = 0.3048,
default = "m/s",
},
["ft/min"] = {
name1 = "foot per minute",
name2 = "feet per minute",
symbol = "ft/min",
utype = "speed",
scale = 0.00508,
default = "m/min",
link = "Feet per second",
},
["ft/s"] = {
name1 = "foot per second",
name2 = "feet per second",
symbol = "ft/s",
utype = "speed",
scale = 0.3048,
default = "m/s",
link = "Feet per second",
},
["furlong per fortnight"] = {
name2 = "furlongs per fortnight",
symbol = "furlong per fortnight",
usename = 1,
utype = "speed",
scale = 0.00016630952380952381,
default = "km/h mph",
link = "FFF system",
},
["in/h"] = {
name1 = "inch per hour",
name2 = "inches per hour",
symbol = "in/h",
utype = "speed",
scale = 7.0555555555555559e-6,
default = "cm/h",
link = "Inch",
},
["in/s"] = {
name1 = "inch per second",
name2 = "inches per second",
symbol = "in/s",
utype = "speed",
scale = 0.0254,
default = "cm/s",
link = "Inch",
},
["in/year"] = {
name1 = "inch per year",
name2 = "inches per year",
symbol = "in/year",
utype = "speed",
scale = 8.0489395807301024e-10,
default = "cm/year",
link = "Orders of magnitude (speed)",
},
["isp"] = {
name1 = "second",
symbol = "s",
utype = "speed",
scale = 9.80665,
default = "km/s",
link = "Specific impulse",
},
["km/d"] = {
name1 = "kilometre per day",
name1_us = "kilometer per day",
name2 = "kilometres per day",
name2_us = "kilometers per day",
symbol = "km/d",
utype = "speed",
scale = 1.1574074074074074e-2,
default = "mi/d",
link = "Orders of magnitude (speed)",
},
["km/h"] = {
name1 = "kilometre per hour",
name1_us = "kilometer per hour",
name2 = "kilometres per hour",
name2_us = "kilometers per hour",
symbol = "km/h",
utype = "speed",
scale = 0.27777777777777779,
default = "mph",
link = "Kilometres per hour",
},
["km/s"] = {
name1 = "kilometre per second",
name1_us = "kilometer per second",
name2 = "kilometres per second",
name2_us = "kilometers per second",
symbol = "km/s",
utype = "speed",
scale = 1000,
default = "mi/s",
link = "Metre per second",
},
["kn"] = {
name1 = "knot",
symbol = "kn",
utype = "speed",
scale = 0.51444444444444448,
default = "km/h mph",
link = "Knot (unit)",
},
["kNs/kg"] = {
name2 = "kN‑s/kg",
symbol = "kN‑s/kg",
utype = "speed",
scale = 1000,
default = "isp",
link = "Specific impulse",
},
["m/min"] = {
name1 = "metre per minute",
name1_us = "meter per minute",
name2 = "metres per minute",
name2_us = "meters per minute",
symbol = "m/min",
utype = "speed",
scale = 0.016666666666666666,
default = "ft/min",
link = "Metre per second",
},
["m/s"] = {
name1 = "metre per second",
name1_us = "meter per second",
name2 = "metres per second",
name2_us = "meters per second",
symbol = "m/s",
utype = "speed",
scale = 1,
default = "ft/s",
},
["Mach"] = {
name2 = "Mach",
symbol = "Mach",
utype = "speed",
builtin = "mach",
scale = 0,
iscomplex= true,
default = "km/h mph",
link = "Mach number",
},
["mi/d"] = {
name1 = "mile per day",
name2 = "miles per day",
symbol = "mi/d",
utype = "speed",
scale = 1.8626666666666667e-2,
default = "km/d",
link = "Orders of magnitude (speed)",
},
["mi/s"] = {
name1 = "mile per second",
name2 = "miles per second",
symbol = "mi/s",
utype = "speed",
scale = 1609.344,
default = "km/s",
link = "Mile",
},
["mm/h"] = {
name1 = "millimetre per hour",
name1_us = "millimeter per hour",
name2 = "millimetres per hour",
name2_us = "millimeters per hour",
symbol = "mm/h",
utype = "speed",
scale = 2.7777777777777781e-7,
default = "in/h",
link = "Metre per second",
},
["mph"] = {
name1 = "mile per hour",
name2 = "miles per hour",
symbol = "mph",
utype = "speed",
scale = 0.44704,
default = "km/h",
link = "Miles per hour",
},
["Ns/kg"] = {
name2 = "N‑s/kg",
symbol = "N‑s/kg",
utype = "speed",
scale = 1,
default = "isp",
link = "Specific impulse",
},
["si tsfc"] = {
name2 = "g/(kN⋅s)",
symbol = "g/(kN⋅s)",
utype = "speed",
scale = 9.9999628621379242e-7,
invert = -1,
iscomplex= true,
default = "tsfc",
link = "Thrust specific fuel consumption",
},
["tsfc"] = {
name2 = "lb/(lbf⋅h)",
symbol = "lb/(lbf⋅h)",
utype = "speed",
scale = 2.832545036049801e-5,
invert = -1,
iscomplex= true,
default = "si tsfc",
link = "Thrust specific fuel consumption",
},
["cm/y"] = {
target = "cm/year",
},
["cm/yr"] = {
target = "cm/year",
},
["in/y"] = {
target = "in/year",
},
["in/yr"] = {
target = "in/year",
},
["knot"] = {
target = "kn",
},
["knots"] = {
target = "kn",
},
["kph"] = {
target = "km/h",
},
["mi/h"] = {
target = "mph",
},
["mm/s"] = {
per = { "mm", "s" },
utype = "speed",
default = "in/s",
link = "Metre per second",
},
["C"] = {
name1 = "degree Celsius",
name2 = "degrees Celsius",
symbol = "°C",
usesymbol= 1,
utype = "temperature",
scale = 1,
offset = -273.15,
iscomplex= true,
istemperature= true,
default = "F",
link = "Celsius",
},
["F"] = {
name1 = "degree Fahrenheit",
name2 = "degrees Fahrenheit",
symbol = "°F",
usesymbol= 1,
utype = "temperature",
scale = 0.55555555555555558,
offset = 32-273.15*(9/5),
iscomplex= true,
istemperature= true,
default = "C",
link = "Fahrenheit",
},
["K"] = {
_name1 = "kelvin",
_symbol = "K",
usesymbol= 1,
utype = "temperature",
scale = 1,
offset = 0,
iscomplex= true,
istemperature= true,
prefixes = 1,
default = "C F",
link = "Kelvin",
},
["keVT"] = {
name1 = "kiloelectronvolt",
symbol = "keV",
utype = "temperature",
scale = 11.604505e6,
offset = 0,
iscomplex= true,
default = "MK",
link = "Electronvolt",
},
["R"] = {
name1 = "degree Rankine",
name2 = "degrees Rankine",
symbol = "°R",
usesymbol= 1,
utype = "temperature",
scale = 0.55555555555555558,
offset = 0,
iscomplex= true,
istemperature= true,
default = "K F C",
link = "Rankine scale",
},
["Celsius"] = {
target = "C",
},
["°C"] = {
target = "C",
},
["°F"] = {
target = "F",
},
["°R"] = {
target = "R",
},
["C-change"] = {
name1 = "degree Celsius change",
name2 = "degrees Celsius change",
symbol = "°C",
usesymbol= 1,
utype = "temperature change",
scale = 1,
default = "F-change",
link = "Celsius",
},
["F-change"] = {
name1 = "degree Fahrenheit change",
name2 = "degrees Fahrenheit change",
symbol = "°F",
usesymbol= 1,
utype = "temperature change",
scale = 0.55555555555555558,
default = "C-change",
link = "Fahrenheit",
},
["K-change"] = {
name1 = "kelvin change",
name2 = "kelvins change",
symbol = "K",
usesymbol= 1,
utype = "temperature change",
scale = 1,
default = "F-change",
link = "Kelvin",
},
["°C-change"] = {
target = "C-change",
},
["°F-change"] = {
target = "F-change",
},
["century"] = {
name1 = "century",
name2 = "centuries",
symbol = "ha",
utype = "time",
scale = 3155760000,
default = "Gs",
},
["d"] = {
name1 = "day",
symbol = "d",
utype = "time",
scale = 86400,
default = "ks",
},
["decade"] = {
name1 = "decade",
symbol = "daa",
utype = "time",
scale = 315576000,
default = "Ms",
},
["dog year"] = {
name1 = "dog year",
symbol = "dog yr",
utype = "time",
scale = 220903200,
default = "years",
link = "List of unusual units of measurement#Dog year",
},
["fortnight"] = {
symbol = "fortnight",
usename = 1,
utype = "time",
scale = 1209600,
default = "week",
},
["h"] = {
name1 = "hour",
symbol = "h",
utype = "time",
scale = 3600,
default = "ks",
},
["long billion year"] = {
name1 = "billion years",
name2 = "billion years",
symbol = "Ta",
utype = "time",
scale = 31557600000000000000,
default = "Es",
link = "Annum",
},
["millennium"] = {
name1 = "millennium",
name2 = "millennia",
symbol = "ka",
utype = "time",
scale = 31557600000,
default = "Gs",
},
["milliard year"] = {
name1 = "milliard years",
name2 = "milliard years",
symbol = "Ga",
utype = "time",
scale = 31557600000000000,
default = "Ps",
link = "Annum",
},
["million year"] = {
name1 = "million years",
name2 = "million years",
symbol = "Ma",
utype = "time",
scale = 31557600000000,
default = "Ts",
link = "Annum",
},
["min"] = {
name1 = "minute",
symbol = "min",
utype = "time",
scale = 60,
default = "s",
},
["month"] = {
symbol = "month",
usename = 1,
utype = "time",
scale = 2629800,
default = "Ms",
},
["months"] = {
name1 = "month",
symbol = "mo",
utype = "time",
scale = 2629800,
default = "year",
},
["s"] = {
_name1 = "second",
_symbol = "s",
utype = "time",
scale = 1,
prefixes = 1,
default = "v < 7200 ! min ! h",
link = "Second",
},
["short billion year"] = {
name1 = "billion years",
name2 = "billion years",
symbol = "Ga",
utype = "time",
scale = 31557600000000000,
default = "Ps",
link = "Annum",
},
["short trillion year"] = {
name1 = "trillion years",
name2 = "trillion years",
symbol = "Ta",
utype = "time",
scale = 31557600000000000000,
default = "Es",
link = "Annum",
},
["thousand million year"] = {
name1 = "thousand million years",
name2 = "thousand million years",
symbol = "Ga",
utype = "time",
scale = 31557600000000000,
default = "Ps",
link = "Annum",
},
["wk"] = {
symbol = "week",
usename = 1,
utype = "time",
scale = 604800,
default = "Ms",
},
["year"] = {
name1 = "year",
symbol = "a",
utype = "time",
scale = 31557600,
default = "Ms",
link = "Annum",
},
["years"] = {
name1 = "year",
symbol = "yr",
utype = "time",
scale = 31557600,
default = "Ms",
link = "Annum",
},
["byr"] = {
target = "short billion year",
},
["day"] = {
target = "d",
},
["days"] = {
target = "d",
},
["dog yr"] = {
target = "dog year",
},
["Gyr"] = {
target = "thousand million year",
},
["hour"] = {
target = "h",
},
["hours"] = {
target = "h",
},
["kMyr"] = {
target = "thousand million year",
},
["kmyr"] = {
target = "thousand million year",
},
["kyr"] = {
target = "millennium",
},
["long byr"] = {
target = "long billion year",
},
["minute"] = {
target = "min",
},
["minutes"] = {
target = "min",
},
["mth"] = {
target = "month",
},
["Myr"] = {
target = "million year",
},
["myr"] = {
target = "million year",
},
["sec"] = {
target = "s",
},
["second"] = {
target = "s",
},
["seconds"] = {
target = "s",
},
["tmyr"] = {
target = "thousand million year",
},
["tryr"] = {
target = "short trillion year",
},
["tyr"] = {
target = "millennium",
},
["week"] = {
target = "wk",
},
["weeks"] = {
target = "wk",
},
["yr"] = {
target = "year",
},
["kg.m"] = {
name1 = "kilogram metre",
name1_us = "kilogram meter",
symbol = "kg⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbft",
link = "Kilogram metre (torque)",
},
["kgf.m"] = {
name1 = "kilogram force-metre",
name1_us = "kilogram force-meter",
symbol = "kgf⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbfft",
link = "Kilogram metre (torque)",
},
["kgm"] = {
name1 = "kilogram metre",
name1_us = "kilogram meter",
symbol = "kg⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbfft",
link = "Kilogram metre (torque)",
},
["kpm"] = {
name1 = "kilopond metre",
name1_us = "kilopond meter",
symbol = "kp⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbft",
link = "Kilogram metre (torque)",
},
["lb-fft"] = {
name1 = "pound force-foot",
name2 = "pound force-feet",
symbol = "ft⋅lb<sub>f</sub>",
utype = "torque",
scale = 1.3558179483314004,
default = "Nm",
link = "Pound-foot (torque)",
},
["lb.ft"] = {
name1 = "pound force-foot",
name2 = "pound force-feet",
symbol = "lb⋅ft",
utype = "torque",
scale = 1.3558179483314004,
default = "Nm",
link = "Pound-foot (torque)",
},
["lb.in"] = {
name1 = "pound force-inch",
symbol = "lb⋅in",
utype = "torque",
scale = 0.1129848290276167,
default = "mN.m",
link = "Pound-foot (torque)",
},
["lbfft"] = {
name1 = "pound force-foot",
name2 = "pound force-feet",
symbol = "lbf⋅ft",
utype = "torque",
scale = 1.3558179483314004,
default = "Nm",
link = "Pound-foot (torque)",
},
["lbft"] = {
name1 = "pound-foot",
name2 = "pound-feet",
symbol = "lb⋅ft",
utype = "torque",
scale = 1.3558179483314004,
default = "Nm",
link = "Pound-foot (torque)",
},
["m.kg-f"] = {
name1 = "metre kilogram-force",
name1_us = "meter kilogram-force",
name2 = "metre kilograms-force",
name2_us = "meter kilograms-force",
symbol = "m⋅kg<sub>f</sub>",
utype = "torque",
scale = 9.80665,
default = "Nm lbfft",
link = "Kilogram metre (torque)",
},
["m.kgf"] = {
name1 = "metre kilogram-force",
name1_us = "meter kilogram-force",
name2 = "metre kilograms-force",
name2_us = "meter kilograms-force",
symbol = "m⋅kgf",
utype = "torque",
scale = 9.80665,
default = "Nm lbfft",
link = "Kilogram metre (torque)",
},
["mN.m"] = {
name1 = "millinewton-metre",
name1_us = "millinewton-meter",
symbol = "mN⋅m",
utype = "torque",
scale = 0.001,
default = "lb.in",
link = "Newton-metre",
},
["Nm"] = {
_name1 = "newton-metre",
_name1_us= "newton-meter",
_symbol = "N⋅m",
utype = "torque",
alttype = "energy",
scale = 1,
prefixes = 1,
default = "lbfft",
link = "Newton-metre",
},
["kN/m"] = {
per = { "kN", "-m-stiff" },
utype = "torque",
default = "lbf/in",
},
["lbf/in"] = {
per = { "lbf", "-in-stiff" },
utype = "torque",
default = "kN/m",
},
["lb-f.ft"] = {
target = "lb-fft",
},
["lbf.ft"] = {
target = "lbfft",
},
["lbf·ft"] = {
target = "lbfft",
},
["lb·ft"] = {
target = "lb.ft",
},
["mkg-f"] = {
target = "m.kg-f",
},
["mkgf"] = {
target = "m.kgf",
},
["N.m"] = {
target = "Nm",
},
["N·m"] = {
target = "Nm",
},
["ton-mile"] = {
symbol = "ton-mile",
usename = 1,
utype = "transportation",
scale = 1.4599723182105602,
default = "tkm",
},
["tkm"] = {
name1 = "tonne-kilometre",
name1_us = "tonne-kilometer",
symbol = "tkm",
utype = "transportation",
scale = 1,
default = "ton-mile",
},
["-12USoz(mL)serve"] = {
name1_us = "12 U.S. fl oz (355 mL) serving",
symbol = "12 US fl oz (355 mL) serving",
sym_us = "12 U.S. fl oz (355 mL) serving",
utype = "volume",
scale = 0.00035488235475000004,
default = "mL",
link = "Beverage can#Standard sizes",
},
["-12USoz(ml)serve"] = {
name1_us = "12 U.S. fl oz (355 ml) serving",
symbol = "12 US fl oz (355 ml) serving",
sym_us = "12 U.S. fl oz (355 ml) serving",
utype = "volume",
scale = 0.00035488235475000004,
default = "ml",
link = "Beverage can#Standard sizes",
},
["-12USozserve"] = {
name1_us = "12 U.S. fl oz serving",
symbol = "12 US fl oz serving",
sym_us = "12 U.S. fl oz serving",
utype = "volume",
scale = 0.00035488235475000004,
default = "mL",
link = "Beverage can#Standard sizes",
},
["acre-foot"] = {
name1 = "acre-foot",
name2 = "acre-foot",
symbol = "acre⋅ft",
utype = "volume",
scale = 1233.48183754752,
default = "m3",
},
["acre-ft"] = {
name1 = "acre-foot",
name2 = "acre-feet",
symbol = "acre⋅ft",
utype = "volume",
scale = 1233.48183754752,
default = "m3",
},
["AUtbsp"] = {
name1 = "Australian tablespoon",
symbol = "AU tbsp",
utype = "volume",
scale = 0.000020,
default = "ml",
},
["Bcuft"] = {
name1 = "billion cubic foot",
name2 = "billion cubic feet",
symbol = "billion cu ft",
utype = "volume",
scale = 28316846.592,
default = "Gl",
link = "Cubic foot",
},
["bdft"] = {
name1 = "board foot",
name2 = "board feet",
symbol = "bd ft",
utype = "volume",
scale = 0.0023597372167,
default = "m3",
},
["board feet"] = {
name2 = "board feet",
symbol = "board foot",
usename = 1,
utype = "volume",
scale = 0.0023597372167,
default = "m3",
},
["board foot"] = {
name2 = "board foot",
symbol = "board foot",
usename = 1,
utype = "volume",
scale = 0.0023597372167,
default = "m3",
},
["cc"] = {
name1 = "cubic centimetre",
name1_us = "cubic centimeter",
symbol = "cc",
utype = "volume",
scale = 0.000001,
default = "cuin",
},
["CID"] = {
name1 = "cubic inch",
name2 = "cubic inches",
symbol = "cu in",
utype = "volume",
scale = 0.000016387064,
default = "cc",
link = "Cubic inch#Engine displacement",
},
["cord"] = {
symbol = "cord",
utype = "volume",
scale = 3.624556363776,
default = "m3",
link = "Cord (unit)",
},
["cufoot"] = {
name1 = "cubic foot",
name2 = "cubic foot",
symbol = "cu ft",
utype = "volume",
scale = 0.028316846592,
default = "m3",
},
["cuft"] = {
name1 = "cubic foot",
name2 = "cubic feet",
symbol = "cu ft",
utype = "volume",
scale = 0.028316846592,
default = "m3",
},
["cuin"] = {
name1 = "cubic inch",
name2 = "cubic inches",
symbol = "cu in",
utype = "volume",
scale = 0.000016387064,
default = "cm3",
},
["cumi"] = {
name1 = "cubic mile",
symbol = "cu mi",
utype = "volume",
scale = 4168181825.440579584,
default = "km3",
},
["cuyd"] = {
name1 = "cubic yard",
symbol = "cu yd",
utype = "volume",
scale = 0.764554857984,
default = "m3",
},
["firkin"] = {
symbol = "firkin",
usename = 1,
utype = "volume",
scale = 0.04091481,
default = "L impgal USgal",
link = "Firkin (unit)",
},
["foot3"] = {
target = "cufoot",
},
["Goilbbl"] = {
name1 = "billion barrels",
name2 = "billion barrels",
symbol = "Gbbl",
utype = "volume",
scale = 158987294.928,
default = "v * 1.58987294928 < 10 ! e6 ! e9 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["gr water"] = {
name1 = "grains water",
name2 = "grains water",
symbol = "gr H<sub>2</sub>O",
utype = "volume",
scale = 0.00000006479891,
default = "cm3",
link = "Grain (unit)",
},
["grt"] = {
name1 = "gross register ton",
symbol = "grt",
utype = "volume",
scale = 2.8316846592,
default = "m3",
link = "Gross register tonnage",
},
["impbbl"] = {
name1 = "imperial barrel",
symbol = "imp bbl",
utype = "volume",
scale = 0.16365924,
default = "L impgal USgal",
link = "Barrel (unit)",
},
["impbsh"] = {
name1 = "imperial bushel",
symbol = "imp bsh",
utype = "volume",
scale = 0.03636872,
default = "L impgal USdrygal",
},
["impbu"] = {
name1 = "imperial bushel",
symbol = "imp bu",
utype = "volume",
scale = 0.03636872,
default = "m3",
},
["impgal"] = {
name1 = "imperial gallon",
symbol = "imp gal",
utype = "volume",
scale = 0.00454609,
default = "L USgal",
},
["impgi"] = {
name1 = "gill",
symbol = "gi",
utype = "volume",
scale = 0.0001420653125,
default = "ml USoz",
link = "Gill (unit)",
},
["impkenning"] = {
name1 = "imperial kenning",
symbol = "kenning",
utype = "volume",
scale = 0.01818436,
default = "L USdrygal",
link = "Kenning (unit)",
},
["impoz"] = {
name1 = "imperial fluid ounce",
symbol = "imp fl oz",
utype = "volume",
scale = 0.0000284130625,
default = "ml USoz",
},
["imppk"] = {
name1 = "imperial peck",
symbol = "pk",
utype = "volume",
scale = 0.00909218,
default = "L USdrygal",
link = "Peck",
},
["imppt"] = {
name1 = "imperial pint",
symbol = "imp pt",
utype = "volume",
scale = 0.00056826125,
default = "L",
},
["impqt"] = {
name1 = "imperial quart",
symbol = "imp qt",
utype = "volume",
scale = 0.0011365225,
default = "ml USoz",
customary= 3,
},
["kilderkin"] = {
symbol = "kilderkin",
usename = 1,
utype = "volume",
scale = 0.08182962,
default = "L impgal USgal",
},
["koilbbl"] = {
name1 = "thousand barrels",
name2 = "thousand barrels",
symbol = "kbbl",
utype = "volume",
scale = 158.987294928,
default = "v * 1.58987294928 < 10 ! ! e3 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["L"] = {
_name1 = "litre",
_name1_us= "liter",
_symbol = "L",
utype = "volume",
scale = 0.001,
prefixes = 1,
default = "impgal USgal",
link = "Litre",
},
["l"] = {
_name1 = "litre",
_name1_us= "liter",
_symbol = "l",
utype = "volume",
scale = 0.001,
prefixes = 1,
default = "impgal USgal",
link = "Litre",
},
["ll"] = {
name1 = "litre",
name1_us = "liter",
symbol = "l",
utype = "volume",
scale = 0.001,
default = "impgal USgal",
},
["m3"] = {
_name1 = "cubic metre",
_name1_us= "cubic meter",
_symbol = "m<sup>3</sup>",
prefix_position= 7,
utype = "volume",
scale = 1,
prefixes = 3,
default = "cuft",
link = "Cubic metre",
},
["Mbbl"] = {
name1 = "thousand barrels",
name2 = "thousand barrels",
symbol = "Mbbl",
utype = "volume",
scale = 158.987294928,
default = "v * 1.58987294928 < 10 ! e3 ! ! m3",
link = "Barrel (unit)#Oil barrel",
},
["MMoilbbl"] = {
name1 = "million barrels",
name2 = "million barrels",
symbol = "MMbbl",
utype = "volume",
scale = 158987.294928,
default = "v * 1.58987294928 < 10 ! e3 ! e6 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["Moilbbl"] = {
name1 = "million barrels",
name2 = "million barrels",
symbol = "Mbbl",
utype = "volume",
scale = 158987.294928,
default = "v * 1.58987294928 < 10 ! e3 ! e6 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["MTON"] = {
name1 = "measurement ton",
symbol = "MTON",
utype = "volume",
scale = 1.13267386368,
default = "m3",
},
["MUSgal"] = {
name1 = "million US gallons",
name1_us = "million U.S. gallons",
name2 = "million US gallons",
name2_us = "million U.S. gallons",
symbol = "million US gal",
sym_us = "million U.S. gal",
utype = "volume",
scale = 3785.411784,
default = "Ml",
link = "US gallon",
},
["oilbbl"] = {
name1 = "barrel",
symbol = "bbl",
utype = "volume",
scale = 0.158987294928,
default = "m3",
link = "Barrel (unit)#Oil barrel",
},
["stere"] = {
symbol = "stere",
usename = 1,
utype = "volume",
scale = 1,
default = "cuft",
},
["Toilbbl"] = {
name1 = "trillion barrels",
name2 = "trillion barrels",
symbol = "Tbbl",
utype = "volume",
scale = 158987294928,
default = "v * 1.58987294928 < 10 ! e9 ! e12 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["USbbl"] = {
name1 = "US barrel",
name1_us = "U.S. barrel",
symbol = "US bbl",
sym_us = "U.S. bbl",
utype = "volume",
scale = 0.119240471196,
default = "L USgal impgal",
link = "Barrel (unit)",
},
["USbeerbbl"] = {
name1 = "US beer barrel",
name1_us = "U.S. beer barrel",
symbol = "US bbl",
sym_us = "U.S. bbl",
utype = "volume",
scale = 0.117347765304,
default = "L USgal impgal",
link = "Barrel (unit)",
},
["USbsh"] = {
name1 = "US bushel",
name1_us = "U.S. bushel",
symbol = "US bsh",
sym_us = "U.S. bsh",
utype = "volume",
scale = 0.03523907016688,
default = "L USdrygal impgal",
link = "Bushel",
},
["USbu"] = {
name1 = "US bushel",
name1_us = "U.S. bushel",
symbol = "US bu",
sym_us = "U.S. bu",
utype = "volume",
scale = 0.03523907016688,
default = "L USdrygal impgal",
link = "Bushel",
},
["USdrybbl"] = {
name1 = "US dry barrel",
name1_us = "U.S. dry barrel",
symbol = "US dry bbl",
sym_us = "U.S. dry bbl",
utype = "volume",
scale = 0.11562819898508,
default = "m3",
link = "Barrel (unit)",
},
["USdrygal"] = {
name1 = "US dry gallon",
name1_us = "U.S. dry gallon",
symbol = "US dry gal",
sym_us = "U.S. dry gal",
utype = "volume",
scale = 0.00440488377086,
default = "L",
link = "Gallon",
},
["USdrypt"] = {
name1 = "US dry pint",
name1_us = "U.S. dry pint",
symbol = "US dry pt",
sym_us = "U.S. dry pt",
utype = "volume",
scale = 0.0005506104713575,
default = "ml",
link = "Pint",
},
["USdryqt"] = {
name1 = "US dry quart",
name1_us = "U.S. dry quart",
symbol = "US dry qt",
sym_us = "U.S. dry qt",
utype = "volume",
scale = 0.001101220942715,
default = "ml",
link = "Quart",
},
["USflgal"] = {
name1 = "US gallon",
name1_us = "U.S. gallon",
symbol = "US fl gal",
sym_us = "U.S. fl gal",
utype = "volume",
scale = 0.003785411784,
default = "L impgal",
link = "Gallon",
},
["USgal"] = {
name1 = "US gallon",
name1_us = "U.S. gallon",
symbol = "US gal",
sym_us = "U.S. gal",
utype = "volume",
scale = 0.003785411784,
default = "L impgal",
},
["USgi"] = {
name1 = "gill",
symbol = "gi",
utype = "volume",
scale = 0.0001182941183,
default = "ml impoz",
link = "Gill (unit)",
},
["USkenning"] = {
name1 = "US kenning",
name1_us = "U.S. kenning",
symbol = "US kenning",
sym_us = "U.S. kenning",
utype = "volume",
scale = 0.01761953508344,
default = "L impgal",
link = "Kenning (unit)",
},
["USmin"] = {
name1 = "US minim",
name1_us = "U.S. minim",
symbol = "US min",
sym_us = "U.S. min",
utype = "volume",
scale = 0.000000061611519921875,
default = "ml",
link = "Minim (unit)",
},
["USoz"] = {
name1 = "US fluid ounce",
name1_us = "U.S. fluid ounce",
symbol = "US fl oz",
sym_us = "U.S. fl oz",
utype = "volume",
scale = 0.0000295735295625,
default = "ml",
},
["USpk"] = {
name1 = "US peck",
name1_us = "U.S. peck",
symbol = "US pk",
sym_us = "U.S. pk",
utype = "volume",
scale = 0.00880976754172,
default = "L impgal",
link = "Peck",
},
["USpt"] = {
name1 = "US pint",
name1_us = "U.S. pint",
symbol = "US pt",
sym_us = "U.S. pt",
utype = "volume",
scale = 0.000473176473,
default = "L imppt",
link = "Pint",
},
["USqt"] = {
name1 = "US quart",
name1_us = "U.S. quart",
symbol = "US qt",
sym_us = "U.S. qt",
utype = "volume",
scale = 0.000946352946,
default = "ml",
link = "Quart",
customary= 1,
},
["USquart"] = {
name1 = "US quart",
name1_us = "U.S. quart",
symbol = "US qt",
sym_us = "U.S. qt",
utype = "volume",
scale = 0.000946352946,
default = "ml impoz",
link = "Quart",
},
["UStbsp"] = {
name1 = "US tablespoon",
name1_us = "U.S. tablespoon",
symbol = "US tbsp",
sym_us = "U.S. tbsp",
utype = "volume",
scale = 1.4786764781250001e-5,
default = "ml",
},
["winecase"] = {
symbol = "case",
usename = 1,
utype = "volume",
scale = 0.009,
default = "L",
link = "Case (goods)",
},
["*U.S.drygal"] = {
target = "USdrygal",
sp_us = true,
customary= 2,
},
["*U.S.gal"] = {
target = "USgal",
sp_us = true,
customary= 2,
},
["+USdrygal"] = {
target = "USdrygal",
customary= 1,
},
["+usfloz"] = {
target = "USoz",
link = "Fluid ounce",
customary= 1,
},
["+USgal"] = {
target = "USgal",
customary= 1,
},
["+USoz"] = {
target = "USoz",
customary= 1,
},
["@impgal"] = {
target = "impgal",
link = "Gallon",
customary= 3,
},
["acre feet"] = {
target = "acre-ft",
},
["acre foot"] = {
target = "acre-foot",
},
["acre ft"] = {
target = "acre-ft",
},
["acre-feet"] = {
target = "acre-ft",
},
["acre.foot"] = {
target = "acre-foot",
},
["acre.ft"] = {
target = "acre-ft",
},
["acre·ft"] = {
target = "acre-ft",
},
["bushels"] = {
target = "USbsh",
},
["cid"] = {
target = "CID",
},
["ft3"] = {
target = "cuft",
},
["gal"] = {
target = "USgal",
},
["gallon"] = {
shouldbe = "Use %{USgal%} for US gallons or %{impgal%} for imperial gallons (not %{gallon%})",
},
["gallons"] = {
shouldbe = "Use %{USgal%} for US gallons or %{impgal%} for imperial gallons (not %{gallons%})",
},
["Gcuft"] = {
target = "e9cuft",
},
["impfloz"] = {
target = "impoz",
},
["Impgal"] = {
target = "impgal",
},
["in3"] = {
target = "cuin",
symbol = "in<sup>3</sup>",
},
["hm³"] = {
target = "hm3",
},
["kcuft"] = {
target = "e3cuft",
},
["kcum"] = {
target = "e3m3",
},
["km³"] = {
target = "km3",
},
["liter"] = {
target = "L",
sp_us = true,
},
["liters"] = {
target = "L",
sp_us = true,
},
["litre"] = {
target = "L",
},
["litres"] = {
target = "L",
},
["Mcuft"] = {
target = "e6cuft",
},
["Mcum"] = {
target = "e6m3",
},
["Mft3"] = {
target = "e6cuft",
},
["mi3"] = {
target = "cumi",
},
["m³"] = {
target = "m3",
},
["Pcuft"] = {
target = "e15cuft",
},
["pt"] = {
shouldbe = "Use %{USpt%} for US pints or %{imppt%} for imperial pints (not %{pt%})",
},
["qt"] = {
shouldbe = "Use %{USqt%} for US quarts or %{impqt%} for imperial quarts (not %{qt%})",
},
["Tcuft"] = {
target = "e12cuft",
},
["Tft3"] = {
target = "e12cuft",
},
["U.S.bbl"] = {
target = "USbbl",
sp_us = true,
default = "L U.S.gal impgal",
},
["U.S.beerbbl"] = {
target = "USbeerbbl",
sp_us = true,
default = "L U.S.gal impgal",
},
["U.S.bsh"] = {
target = "USbsh",
sp_us = true,
default = "L U.S.drygal impgal",
},
["U.S.bu"] = {
target = "USbu",
sp_us = true,
default = "L U.S.drygal impgal",
},
["U.S.drybbl"] = {
target = "USdrybbl",
sp_us = true,
},
["U.S.drygal"] = {
target = "USdrygal",
sp_us = true,
},
["U.S.drypt"] = {
target = "USdrypt",
sp_us = true,
},
["U.S.dryqt"] = {
target = "USdryqt",
sp_us = true,
},
["U.S.flgal"] = {
target = "USflgal",
sp_us = true,
},
["U.S.floz"] = {
target = "USoz",
sp_us = true,
},
["U.S.gal"] = {
target = "USgal",
sp_us = true,
link = "U.S. gallon",
},
["u.s.gal"] = {
target = "USgal",
sp_us = true,
link = "U.S. gallon",
},
["U.S.gi"] = {
target = "USgi",
sp_us = true,
},
["U.S.kenning"] = {
target = "USkenning",
sp_us = true,
},
["U.S.oz"] = {
target = "USoz",
sp_us = true,
},
["U.S.pk"] = {
target = "USpk",
sp_us = true,
},
["U.S.pt"] = {
target = "USpt",
sp_us = true,
},
["U.S.qt"] = {
target = "USqt",
sp_us = true,
default = "L impqt",
customary= 2,
},
["usbbl"] = {
target = "USbbl",
},
["usbeerbbl"] = {
target = "USbeerbbl",
},
["usbsh"] = {
target = "USbsh",
},
["usbu"] = {
target = "USbu",
},
["usdrybbl"] = {
target = "USdrybbl",
},
["usdrygal"] = {
target = "USdrygal",
},
["usdrypt"] = {
target = "USdrypt",
},
["usdryqt"] = {
target = "USdryqt",
},
["USfloz"] = {
target = "USoz",
},
["usfloz"] = {
target = "USoz",
},
["USGAL"] = {
target = "USgal",
},
["usgal"] = {
target = "USgal",
},
["usgi"] = {
target = "USgi",
},
["uskenning"] = {
target = "USkenning",
},
["usoz"] = {
target = "USoz",
},
["uspk"] = {
target = "USpk",
},
["uspt"] = {
target = "USpt",
},
["usqt"] = {
target = "USqt",
},
["yd3"] = {
target = "cuyd",
},
["cuft/sqmi"] = {
per = { "cuft", "sqmi" },
utype = "volume per unit area",
default = "m3/km2",
},
["m3/ha"] = {
name1 = "cubic metre per hectare",
name1_us = "cubic meter per hectare",
name2 = "cubic metres per hectare",
name2_us = "cubic meters per hectare",
symbol = "m<sup>3</sup>/ha",
utype = "volume per unit area",
scale = 0.0001,
default = "USbu/acre",
link = "Hectare",
},
["m3/km2"] = {
per = { "m3", "km2" },
utype = "volume per unit area",
default = "cuft/sqmi",
},
["U.S.gal/acre"] = {
per = { "U.S.gal", "acre" },
utype = "volume per unit area",
default = "m3/km2",
},
["USbu/acre"] = {
name2 = "US bushels per acre",
symbol = "US bushel per acre",
usename = 1,
utype = "volume per unit area",
scale = 8.7077638761350888e-6,
default = "m3/ha",
link = "Bushel",
},
["USgal/acre"] = {
per = { "USgal", "acre" },
utype = "volume per unit area",
default = "m3/km2",
},
["cuyd/mi"] = {
per = { "cuyd", "mi" },
utype = "volume per unit length",
default = "m3/km",
},
["m3/km"] = {
per = { "m3", "km" },
utype = "volume per unit length",
default = "cuyd/mi",
},
["mich"] = {
combination= { "ch", "mi" },
multiple = { 80 },
utype = "length",
},
["michlk"] = {
combination= { "chlk", "mi" },
multiple = { 80 },
utype = "length",
},
["michainlk"] = {
combination= { "chainlk", "mi" },
multiple = { 80 },
utype = "length",
},
["miyd"] = {
combination= { "yd", "mi" },
multiple = { 1760 },
utype = "length",
},
["miydftin"] = {
combination= { "in", "ft", "yd", "mi" },
multiple = { 12, 3, 1760 },
utype = "length",
},
["mift"] = {
combination= { "ft", "mi" },
multiple = { 5280 },
utype = "length",
},
["ydftin"] = {
combination= { "in", "ft", "yd" },
multiple = { 12, 3 },
utype = "length",
},
["ydft"] = {
combination= { "ft", "yd" },
multiple = { 3 },
utype = "length",
},
["ftin"] = {
combination= { "in", "ft" },
multiple = { 12 },
utype = "length",
},
["footin"] = {
combination= { "in", "foot" },
multiple = { 12 },
utype = "length",
},
["handin"] = {
combination= { "in", "hand" },
multiple = { 4 },
utype = "length",
},
["lboz"] = {
combination= { "oz", "lb" },
multiple = { 16 },
utype = "mass",
},
["stlb"] = {
combination= { "lb", "st" },
multiple = { 14 },
utype = "mass",
},
["stlboz"] = {
combination= { "oz", "lb", "st" },
multiple = { 16, 14 },
utype = "mass",
},
["st and lb"] = {
combination= { "lb", "st" },
multiple = { 14 },
utype = "mass",
},
["GN LTf"] = {
combination= { "GN", "-LTf" },
utype = "force",
},
["GN LTf STf"] = {
combination= { "GN", "-LTf", "-STf" },
utype = "force",
},
["GN STf"] = {
combination= { "GN", "-STf" },
utype = "force",
},
["GN STf LTf"] = {
combination= { "GN", "-STf", "-LTf" },
utype = "force",
},
["kN LTf"] = {
combination= { "kN", "-LTf" },
utype = "force",
},
["kN LTf STf"] = {
combination= { "kN", "-LTf", "-STf" },
utype = "force",
},
["kN STf"] = {
combination= { "kN", "-STf" },
utype = "force",
},
["kN STf LTf"] = {
combination= { "kN", "-STf", "-LTf" },
utype = "force",
},
["LTf STf"] = {
combination= { "-LTf", "-STf" },
utype = "force",
},
["MN LTf"] = {
combination= { "MN", "-LTf" },
utype = "force",
},
["MN LTf STf"] = {
combination= { "MN", "-LTf", "-STf" },
utype = "force",
},
["MN STf"] = {
combination= { "MN", "-STf" },
utype = "force",
},
["MN STf LTf"] = {
combination= { "MN", "-STf", "-LTf" },
utype = "force",
},
["STf LTf"] = {
combination= { "-STf", "-LTf" },
utype = "force",
},
["L/100 km mpgimp"] = {
combination= { "L/100 km", "mpgimp" },
utype = "fuel efficiency",
},
["l/100 km mpgimp"] = {
combination= { "l/100 km", "mpgimp" },
utype = "fuel efficiency",
},
["L/100 km mpgUS"] = {
combination= { "L/100 km", "mpgus" },
utype = "fuel efficiency",
},
["L/100 km mpgus"] = {
combination= { "L/100 km", "mpgus" },
utype = "fuel efficiency",
},
["l/100 km mpgus"] = {
combination= { "l/100 km", "mpgus" },
utype = "fuel efficiency",
},
["mpgimp L/100 km"] = {
combination= { "mpgimp", "L/100 km" },
utype = "fuel efficiency",
},
["LT ST t"] = {
combination= { "lt", "-ST", "t" },
utype = "mass",
},
["LT t ST"] = {
combination= { "lt", "t", "-ST" },
utype = "mass",
},
["ST LT t"] = {
combination= { "-ST", "lt", "t" },
utype = "mass",
},
["ST t LT"] = {
combination= { "-ST", "t", "lt" },
utype = "mass",
},
["t LT ST"] = {
combination= { "t", "lt", "-ST" },
utype = "mass",
},
["ton"] = {
combination= { "LT", "ST" },
utype = "mass",
},
["kPa kg/cm2"] = {
combination= { "kPa", "kgf/cm2" },
utype = "pressure",
},
["kPa lb/in2"] = {
combination= { "kPa", "-lb/in2" },
utype = "pressure",
},
["floz"] = {
combination= { "impoz", "USoz" },
utype = "volume",
},
}
---------------------------------------------------------------------------
-- Do not change the data in this table because it is created by running --
-- a script that reads the wikitext from a wiki page (see note above). --
---------------------------------------------------------------------------
local default_exceptions = {
-- Prefixed units with a default different from that of the base unit.
-- Each key item is a prefixed symbol (unitcode for engineering notation).
["cm<sup>2</sup>"] = "sqin",
["dm<sup>2</sup>"] = "sqin",
["e3acre"] = "km2",
["e3m2"] = "e6sqft",
["e6acre"] = "km2",
["e6ha"] = "e6acre",
["e6km2"] = "e6sqmi",
["e6m2"] = "e6sqft",
["e6sqft"] = "v * 9.290304 < 100 ! e3 ! e6 ! m2",
["e6sqmi"] = "e6km2",
["hm<sup>2</sup>"] = "acre",
["km<sup>2</sup>"] = "sqmi",
["mm<sup>2</sup>"] = "sqin",
["aJ"] = "eV",
["e3BTU"] = "MJ",
["e6BTU"] = "GJ",
["EJ"] = "kWh",
["fJ"] = "keV",
["GJ"] = "kWh",
["MJ"] = "kWh",
["PJ"] = "kWh",
["pJ"] = "MeV",
["TJ"] = "kWh",
["YJ"] = "kWh",
["yJ"] = "μeV",
["ZJ"] = "kWh",
["zJ"] = "meV",
["e12cuft/a"] = "v * 2.8316846592 < 100 ! e9 ! e12 ! m3/a",
["e12cuft/d"] = "v * 2.8316846592 < 100 ! e9 ! e12 ! m3/d",
["e12m3/a"] = "Tcuft/a",
["e12m3/d"] = "Tcuft/d",
["e3cuft/a"] = "v * 2.8316846592 < 100 ! ! e3 ! m3/a",
["e3cuft/d"] = "v * 2.8316846592 < 100 ! ! e3 ! m3/d",
["e3cuft/s"] = "v * 2.8316846592 < 100 ! ! e3 ! m3/s",
["e3m3/a"] = "v < 28.316846592 ! k ! M ! cuft/a",
["e3m3/d"] = "v < 28.316846592 ! k ! M ! cuft/d",
["e3m3/s"] = "v < 28.316846592 ! k ! M ! cuft/s",
["e3USgal/a"] = "v * 3.785411784 < 1000 ! ! e3 ! m3/a",
["e6cuft/a"] = "v * 2.8316846592 < 100 ! e3 ! e6 ! m3/a",
["e6cuft/d"] = "v * 2.8316846592 < 100 ! e3 ! e6 ! m3/d",
["e6cuft/s"] = "v * 2.8316846592 < 100 ! e3 ! e6 ! m3/s",
["e6m3/a"] = "v < 28.316846592 ! M ! G ! cuft/a",
["e6m3/d"] = "v < 28.316846592 ! M ! G ! cuft/d",
["e6m3/s"] = "v < 28.316846592 ! e6 ! e9 ! cuft/s",
["e6USgal/a"] = "v * 3.785411784 < 1000 ! e3 ! e6 ! m3/a",
["e9cuft/a"] = "m3/a",
["e9cuft/d"] = "v * 2.8316846592 < 100 ! e6 ! e9 ! m3/d",
["e9m3/a"] = "v < 28.316846592 ! G ! T ! cuft/a",
["e9m3/d"] = "v < 28.316846592 ! G ! T ! cuft/d",
["e9m3/s"] = "v < 28.316846592 ! e9 ! e12 ! cuft/s",
["e9USgal/a"] = "v * 3.785411784 < 1000 ! e6 ! e9 ! m3/a",
["e9USgal/s"] = "v * 3.785411784 < 1000 ! e6 ! e9 ! m3/s",
["nN"] = "gr-f",
["μN"] = "gr-f",
["mN"] = "oz-f",
["am"] = "in",
["cm"] = "in",
["dam"] = "ft",
["dm"] = "in",
["e12km"] = "e12mi",
["e12mi"] = "e12km",
["e3AU"] = "ly",
["e3km"] = "e3mi",
["e3mi"] = "e3km",
["e6km"] = "e6mi",
["e6mi"] = "e6km",
["e9km"] = "AU",
["e9mi"] = "e9km",
["Em"] = "mi",
["fm"] = "in",
["Gm"] = "mi",
["hm"] = "ft",
["km"] = "mi",
["mm"] = "in",
["Mm"] = "mi",
["nm"] = "in",
["Pm"] = "mi",
["pm"] = "in",
["Tm"] = "mi",
["Ym"] = "mi",
["ym"] = "in",
["Zm"] = "mi",
["zm"] = "in",
["μm"] = "in",
["e12lb"] = "v * 4.5359237 < 10 ! Mt ! Gt",
["e3lb"] = "v * 4.5359237 < 10 ! kg ! t",
["e3ozt"] = "v * 0.311034768 < 10 ! kg ! t",
["e3t"] = "LT ST",
["e6carat"] = "t",
["e6lb"] = "v * 4.5359237 < 10 ! t ! kilotonne",
["e6ozt"] = "lb kg",
["e6ST"] = "Mt",
["e6t"] = "LT ST",
["e9lb"] = "v * 4.5359237 < 10 ! kilotonne ! Mt",
["e9t"] = "LT ST",
["Gg"] = "lb",
["kg"] = "lb",
["mg"] = "gr",
["Mg"] = "LT ST",
["ng"] = "gr",
["μg"] = "gr",
["mBq"] = "fCi",
["kBq"] = "nCi",
["MBq"] = "μCi",
["GBq"] = "mCi",
["TBq"] = "Ci",
["PBq"] = "kCi",
["EBq"] = "kCi",
["fCi"] = "mBq",
["pCi"] = "Bq",
["nCi"] = "Bq",
["μCi"] = "kBq",
["mCi"] = "MBq",
["kCi"] = "TBq",
["MCi"] = "PBq",
["ns"] = "μs",
["μs"] = "ms",
["ms"] = "s",
["ks"] = "h",
["Ms"] = "week",
["Gs"] = "decade",
["Ts"] = "millennium",
["Ps"] = "million year",
["Es"] = "thousand million year",
["MK"] = "keVT",
["cL"] = "impoz usoz",
["cl"] = "impoz usoz",
["cm<sup>3</sup>"] = "cuin",
["dL"] = "impoz usoz",
["dl"] = "impoz usoz",
["mm<sup>3</sup>"] = "cuin",
["dm<sup>3</sup>"] = "cuin",
["e12cuft"] = "v * 2.8316846592 < 100 ! e9 ! e12 ! m3",
["e12impgal"] = "v * 4.54609 < 1000 ! T ! P ! l",
["e12m3"] = "v < 28.316846592 ! T ! P ! cuft",
["e12U.S.gal"] = "v * 3.785411784 < 1000 ! T ! P ! l",
["e12USgal"] = "v * 3.785411784 < 1000 ! T ! P ! l",
["e15cuft"] = "v * 2.8316846592 < 100 ! e12 ! e15 ! m3",
["e15m3"] = "Pcuft",
["e3bdft"] = "v * 0.23597372167 < 100 ! e3 ! e6 ! m3",
["e3cuft"] = "v * 2.8316846592 < 100 ! ! e3 ! m3",
["e3impgal"] = "v * 4.54609 < 1000 ! k ! M ! l",
["e3m3"] = "v < 28.316846592 ! k ! M ! cuft",
["e3U.S.gal"] = "v * 3.785411784 < 1000 ! k ! M ! l",
["e3USgal"] = "v * 3.785411784 < 1000 ! k ! M ! l",
["e6bdft"] = "v * 0.23597372167 < 100 ! e3 ! e6 ! m3",
["e6cuft"] = "v * 2.8316846592 < 100 ! e3 ! e6 ! m3",
["e6cuyd"] = "v * 7.64554857984 < 10 ! e3 ! e6 ! m3",
["e6impgal"] = "v * 4.54609 < 1000 ! M ! G ! l",
["e6L"] = "USgal",
["e6m3"] = "v < 28.316846592 ! M ! G ! cuft",
["e6U.S.gal"] = "v * 3.785411784 < 1000 ! M ! G ! l",
["e6USgal"] = "v * 3.785411784 < 1000 ! M ! G ! l",
["e9bdft"] = "v * 0.23597372167 < 100 ! e6 ! e9 ! m3",
["e9cuft"] = "v * 2.8316846592 < 100 ! e6 ! e9 ! m3",
["e9impgal"] = "v * 4.54609 < 1000 ! G ! T ! l",
["e9m3"] = "v < 28.316846592 ! G ! T ! cuft",
["e9U.S.gal"] = "v * 3.785411784 < 1000 ! G ! T ! l",
["e9USgal"] = "v * 3.785411784 < 1000 ! G ! T ! l",
["GL"] = "cuft",
["Gl"] = "cuft",
["kL"] = "cuft",
["kl"] = "cuft",
["km<sup>3</sup>"] = "cumi",
["mL"] = "impoz usoz",
["ml"] = "impoz usoz",
["Ml"] = "v < 28.316846592 ! e3 ! e6 ! cuft",
["ML"] = "v < 28.316846592 ! e3 ! e6 ! cuft",
["TL"] = "cumi",
["Tl"] = "cumi",
["μL"] = "cuin",
["μl"] = "cuin",
}
---------------------------------------------------------------------------
-- Do not change the data in this table because it is created by running --
-- a script that reads the wikitext from a wiki page (see note above). --
---------------------------------------------------------------------------
local link_exceptions = {
-- Prefixed units with a linked article different from that of the base unit.
-- Each key item is a prefixed symbol (not unitcode).
["mm<sup>2</sup>"] = "Square millimetre",
["cm<sup>2</sup>"] = "Square centimetre",
["dm<sup>2</sup>"] = "Square decimetre",
["km<sup>2</sup>"] = "Square kilometre",
["kJ"] = "Kilojoule",
["MJ"] = "Megajoule",
["GJ"] = "Gigajoule",
["TJ"] = "Terajoule",
["fm"] = "Femtometre",
["pm"] = "Picometre",
["nm"] = "Nanometre",
["μm"] = "Micrometre",
["mm"] = "Millimetre",
["cm"] = "Centimetre",
["dm"] = "Decimetre",
["dam"] = "Decametre",
["hm"] = "Hectometre",
["km"] = "Kilometre",
["Mm"] = "Megametre",
["Gm"] = "Gigametre",
["Tm"] = "Terametre",
["Pm"] = "Petametre",
["Em"] = "Exametre",
["Zm"] = "Zettametre",
["Ym"] = "Yottametre",
["μg"] = "Microgram",
["mg"] = "Milligram",
["kg"] = "Kilogram",
["Mg"] = "Tonne",
["yW"] = "Yoctowatt",
["zW"] = "Zeptowatt",
["aW"] = "Attowatt",
["fW"] = "Femtowatt",
["pW"] = "Picowatt",
["nW"] = "Nanowatt",
["μW"] = "Microwatt",
["mW"] = "Milliwatt",
["kW"] = "Kilowatt",
["MW"] = "Megawatt",
["GW"] = "Gigawatt",
["TW"] = "Terawatt",
["PW"] = "Petawatt",
["EW"] = "Exawatt",
["ZW"] = "Zettawatt",
["YW"] = "Yottawatt",
["as"] = "Attosecond",
["fs"] = "Femtosecond",
["ps"] = "Picosecond",
["ns"] = "Nanosecond",
["μs"] = "Microsecond",
["ms"] = "Millisecond",
["ks"] = "Kilosecond",
["Ms"] = "Megasecond",
["Gs"] = "Gigasecond",
["Ts"] = "Terasecond",
["Ps"] = "Petasecond",
["Es"] = "Exasecond",
["Zs"] = "Zettasecond",
["Ys"] = "Yottasecond",
["mm<sup>3</sup>"] = "Cubic millimetre",
["cm<sup>3</sup>"] = "Cubic centimetre",
["dm<sup>3</sup>"] = "Cubic decimetre",
["dam<sup>3</sup>"] = "Cubic decametre",
["km<sup>3</sup>"] = "Cubic kilometre",
["μL"] = "Microlitre",
["μl"] = "Microlitre",
["mL"] = "Millilitre",
["ml"] = "Millilitre",
["cL"] = "Centilitre",
["cl"] = "Centilitre",
["dL"] = "Decilitre",
["dl"] = "Decilitre",
["daL"] = "Decalitre",
["dal"] = "Decalitre",
["hL"] = "Hectolitre",
["hl"] = "Hectolitre",
["kL"] = "Kilolitre",
["kl"] = "Kilolitre",
["ML"] = "Megalitre",
["Ml"] = "Megalitre",
["GL"] = "Gigalitre",
["Gl"] = "Gigalitre",
["TL"] = "Teralitre",
["Tl"] = "Teralitre",
["PL"] = "Petalitre",
["Pl"] = "Petalitre",
}
---------------------------------------------------------------------------
-- Do not change the data in this table because it is created by running --
-- a script that reads the wikitext from a wiki page (see note above). --
---------------------------------------------------------------------------
local per_unit_fixups = {
-- Automatically created per units of form "x/y" may have their unit type
-- changed, for example, "length/time" is changed to "speed".
-- Other adjustments can also be specified.
["/area"] = "per unit area",
["/volume"] = "per unit volume",
["area/area"] = "area per unit area",
["energy/length"] = "energy per unit length",
["energy/mass"] = "energy per unit mass",
["energy/time"] = { utype = "power", link = "Power (physics)" },
["energy/volume"] = "energy per unit volume",
["force/area"] = { utype = "pressure", link = "Pressure" },
["length/length"] = { utype = "gradient", link = "Grade (slope)" },
["length/time"] = { utype = "speed", link = "Speed" },
["length/time/time"] = { utype = "acceleration", link = "Acceleration" },
["mass/area"] = { utype = "pressure", multiplier = 9.80665 },
["mass/length"] = "linear density",
["mass/mass"] = "concentration",
["mass/power"] = "mass per unit power",
["mass/time"] = "mass per unit time",
["mass/volume"] = { utype = "density", link = "Density" },
["power/mass"] = "power per unit mass",
["power/volume"] = { link = "Power density" },
["pressure/length"] = "fracture gradient",
["speed/time"] = { utype = "acceleration", link = "Acceleration" },
["volume/area"] = "volume per unit area",
["volume/length"] = "volume per unit length",
["volume/time"] = "flow",
}
return {
all_units = all_units,
default_exceptions = default_exceptions,
link_exceptions = link_exceptions,
per_unit_fixups = per_unit_fixups,
}
8d4f7e3d03f55a7683bae4e0b800b77ac91d44a2
Module:Convert
828
88
179
2023-05-10T03:20:21Z
w>Johnuniq
0
update from sandbox per [[Template talk:Convert#Module version 29]]
Scribunto
text/plain
-- Convert a value from one unit of measurement to another.
-- Example: {{convert|123|lb|kg}} --> 123 pounds (56 kg)
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
local MINUS = '−' -- Unicode U+2212 MINUS SIGN (UTF-8: e2 88 92)
local abs = math.abs
local floor = math.floor
local format = string.format
local log10 = math.log10
local ustring = mw.ustring
local ulen = ustring.len
local usub = ustring.sub
-- Configuration options to keep magic values in one location.
-- Conversion data and message text are defined in separate modules.
local config, maxsigfig
local numdot -- must be '.' or ',' or a character which works in a regex
local numsep, numsep_remove, numsep_remove2
local data_code, all_units
local text_code
local varname -- can be a code to use variable names that depend on value
local from_en_table -- to translate an output string of en digits to local language
local to_en_table -- to translate an input string of digits in local language to en
-- Use translation_table in convert/text to change the following.
local en_default -- true uses lang=en unless convert has lang=local or local digits
local group_method = 3 -- code for how many digits are in a group
local per_word = 'per' -- for units like "liters per kilometer"
local plural_suffix = 's' -- only other useful value is probably '' to disable plural unit names
local omitsep -- true to omit separator before local symbol/name
-- All units should be defined in the data module. However, to cater for quick changes
-- and experiments, any unknown unit is looked up in an extra data module, if it exists.
-- That module would be transcluded in only a small number of pages, so there should be
-- little server overhead from making changes, and changes should propagate quickly.
local extra_module -- name of module with extra units
local extra_units -- nil or table of extra units from extra_module
-- Some options in the invoking template can set variables used later in the module.
local currency_text -- for a user-defined currency symbol: {{convert|12|$/ha|$=€}} (euro replaces dollar)
local function from_en(text)
-- Input is a string representing a number in en digits with '.' decimal mark,
-- without digit grouping (which is done just after calling this).
-- Return the translation of the string with numdot and digits in local language.
if numdot ~= '.' then
text = text:gsub('%.', numdot)
end
if from_en_table then
text = text:gsub('%d', from_en_table)
end
return text
end
local function to_en(text)
-- Input is a string representing a number in the local language with
-- an optional numdot decimal mark and numsep digit grouping.
-- Return the translation of the string with '.' mark and en digits,
-- and no separators (they have to be removed here to handle cases like
-- numsep = '.' and numdot = ',' with input "1.234.567,8").
if to_en_table then
text = ustring.gsub(text, '%d', to_en_table)
end
if numsep_remove then
text = text:gsub(numsep_remove, '')
end
if numsep_remove2 then
text = text:gsub(numsep_remove2, '')
end
if numdot ~= '.' then
text = text:gsub(numdot, '.')
end
return text
end
local function decimal_mark(text)
-- Return ',' if text probably is using comma for decimal mark, or has no decimal mark.
-- Return '.' if text probably is using dot for decimal mark.
-- Otherwise return nothing (decimal mark not known).
if not text:find('[.,]') then return ',' end
text = text:gsub('^%-', ''):gsub('%+%d+/%d+$', ''):gsub('[Ee]%-?%d+$', '')
local decimal =
text:match('^0?([.,])%d+$') or
text:match('%d([.,])%d?%d?$') or
text:match('%d([.,])%d%d%d%d+$')
if decimal then return decimal end
if text:match('%.%d+%.') then return ',' end
if text:match('%,%d+,') then return '.' end
end
local add_warning, with_separator -- forward declarations
local function to_en_with_check(text, parms)
-- Version of to_en() for a wiki using numdot = ',' and numsep = '.' to check
-- text (an input number as a string) which might have been copied from enwiki.
-- For example, in '1.234' the '.' could be a decimal mark or a group separator.
-- From viwiki.
if to_en_table then
text = ustring.gsub(text, '%d', to_en_table)
end
if decimal_mark(text) == '.' then
local original = text
text = text:gsub(',', '') -- for example, interpret "1,234.5" as an enwiki value
if parms then
add_warning(parms, 0, 'cvt_enwiki_num', original, with_separator({}, text))
end
else
if numsep_remove then
text = text:gsub(numsep_remove, '')
end
if numsep_remove2 then
text = text:gsub(numsep_remove2, '')
end
if numdot ~= '.' then
text = text:gsub(numdot, '.')
end
end
return text
end
local function omit_separator(id)
-- Return true if there should be no separator before id (a unit symbol or name).
-- For zhwiki, there should be no separator if id uses local characters.
-- The following kludge should be a sufficient test.
if omitsep then
if id:sub(1, 2) == '-{' then -- for "-{...}-" content language variant
return true
end
if id:byte() > 127 then
local first = usub(id, 1, 1)
if first ~= 'Å' and first ~= '°' and first ~= 'µ' then
return true
end
end
end
return id:sub(1, 1) == '/' -- no separator before units like "/ha"
end
local spell_module -- name of module that can spell numbers
local speller -- function from that module to handle spelling (set if needed)
local wikidata_module, wikidata_data_module -- names of Wikidata modules
local wikidata_code, wikidata_data -- exported tables from those modules (set if needed)
local function set_config(args)
-- Set configuration options from template #invoke or defaults.
config = args
maxsigfig = config.maxsigfig or 14 -- maximum number of significant figures
local data_module, text_module
local sandbox = config.sandbox and ('/' .. config.sandbox) or ''
data_module = "Module:Convert/data" .. sandbox
text_module = "Module:Convert/text" .. sandbox
extra_module = "Module:Convert/extra" .. sandbox
wikidata_module = "Module:Convert/wikidata" .. sandbox
wikidata_data_module = "Module:Convert/wikidata/data" .. sandbox
spell_module = "Module:ConvertNumeric"
data_code = mw.loadData(data_module)
text_code = mw.loadData(text_module)
all_units = data_code.all_units
local translation = text_code.translation_table
if translation then
numdot = translation.numdot
numsep = translation.numsep
if numdot == ',' and numsep == '.' then
if text_code.all_messages.cvt_enwiki_num then
to_en = to_en_with_check
end
end
if translation.group then
group_method = translation.group
end
if translation.per_word then
per_word = translation.per_word
end
if translation.plural_suffix then
plural_suffix = translation.plural_suffix
end
varname = translation.varname
from_en_table = translation.from_en
local use_workaround = true
if use_workaround then
-- 2013-07-05 workaround bug by making a copy of the required table.
-- mw.ustring.gsub fails with a table (to_en_table) as the replacement,
-- if the table is accessed via mw.loadData.
local source = translation.to_en
if source then
to_en_table = {}
for k, v in pairs(source) do
to_en_table[k] = v
end
end
else
to_en_table = translation.to_en
end
if translation.lang == 'en default' then
en_default = true -- for hiwiki
end
omitsep = translation.omitsep -- for zhwiki
end
numdot = config.numdot or numdot or '.' -- decimal mark before fractional digits
numsep = config.numsep or numsep or ',' -- group separator for numbers
-- numsep should be ',' or '.' or '' or ' ' or a Unicode character.
-- numsep_remove must work in a regex to identify separators to be removed.
if numsep ~= '' then
numsep_remove = (numsep == '.') and '%.' or numsep
end
if numsep ~= ',' and numdot ~= ',' then
numsep_remove2 = ',' -- so numbers copied from enwiki will work
end
end
local function collection()
-- Return a table to hold items.
return {
n = 0,
add = function (self, item)
self.n = self.n + 1
self[self.n] = item
end,
}
end
local function divide(numerator, denominator)
-- Return integers quotient, remainder resulting from dividing the two
-- given numbers, which should be unsigned integers.
local quotient, remainder = floor(numerator / denominator), numerator % denominator
if not (0 <= remainder and remainder < denominator) then
-- Floating point limits may need this, as in {{convert|160.02|Ym|ydftin}}.
remainder = 0
end
return quotient, remainder
end
local function split(text, delimiter)
-- Return a numbered table with fields from splitting text.
-- The delimiter is used in a regex without escaping (for example, '.' would fail).
-- Each field has any leading/trailing whitespace removed.
local t = {}
text = text .. delimiter -- to get last item
for item in text:gmatch('%s*(.-)%s*' .. delimiter) do
table.insert(t, item)
end
return t
end
local function strip(text)
-- If text is a string, return its content with no leading/trailing
-- whitespace. Otherwise return nil (a nil argument gives a nil result).
if type(text) == 'string' then
return text:match("^%s*(.-)%s*$")
end
end
local function table_len(t)
-- Return length (<100) of a numbered table to replace #t which is
-- documented to not work if t is accessed via mw.loadData().
for i = 1, 100 do
if t[i] == nil then
return i - 1
end
end
end
local function wanted_category(catkey, catsort, want_warning)
-- Return message category if it is wanted in current namespace,
-- otherwise return ''.
local cat
local title = mw.title.getCurrentTitle()
if title then
local nsdefault = '0' -- default namespace: '0' = article; '0,10' = article and template
local namespace = title.namespace
for _, v in ipairs(split(config.nscat or nsdefault, ',')) do
if namespace == tonumber(v) then
cat = text_code.all_categories[want_warning and 'warning' or catkey]
if catsort and catsort ~= '' and cat:sub(-2) == ']]' then
cat = cat:sub(1, -3) .. '|' .. mw.text.nowiki(usub(catsort, 1, 20)) .. ']]'
end
break
end
end
end
return cat or ''
end
local function message(parms, mcode, is_warning)
-- Return wikitext for an error message, including category if specified
-- for the message type.
-- mcode = numbered table specifying the message:
-- mcode[1] = 'cvt_xxx' (string used as a key to get message info)
-- mcode[2] = 'parm1' (string to replace '$1' if any in message)
-- mcode[3] = 'parm2' (string to replace '$2' if any in message)
-- mcode[4] = 'parm3' (string to replace '$3' if any in message)
local msg
if type(mcode) == 'table' then
if mcode[1] == 'cvt_no_output' then
-- Some errors should cause convert to output an empty string,
-- for example, for an optional field in an infobox.
return ''
end
msg = text_code.all_messages[mcode[1]]
end
parms.have_problem = true
local function subparm(fmt, ...)
local rep = {}
for i, v in ipairs({...}) do
rep['$' .. i] = v
end
return (fmt:gsub('$%d+', rep))
end
if msg then
local parts = {}
local regex, replace = msg.regex, msg.replace
for i = 1, 3 do
local limit = 40
local s = mcode[i + 1]
if s then
if regex and replace then
s = s:gsub(regex, replace)
limit = nil -- allow long "should be" messages
end
-- Escape user input so it does not break the message.
-- To avoid tags (like {{convert|1<math>23</math>|m}}) breaking
-- the mouseover title, any strip marker starting with char(127) is
-- replaced with '...' (text not needing i18n).
local append
local pos = s:find(string.char(127), 1, true)
if pos then
append = '...'
s = s:sub(1, pos - 1)
end
if limit and ulen(s) > limit then
s = usub(s, 1, limit)
append = '...'
end
s = mw.text.nowiki(s) .. (append or '')
else
s = '?'
end
parts['$' .. i] = s
end
local function ispreview()
-- Return true if a prominent message should be shown.
if parms.test == 'preview' or parms.test == 'nopreview' then
-- For testing, can preview a real message or simulate a preview
-- when running automated tests.
return parms.test == 'preview'
end
local success, revid = pcall(function ()
return (parms.frame):preprocess('{{REVISIONID}}') end)
return success and (revid == '')
end
local want_warning = is_warning and
not config.warnings and -- show unobtrusive warnings if config.warnings not configured
not msg.nowarn -- but use msg settings, not standard warning, if specified
local title = string.gsub(msg[1] or 'Missing message', '$%d+', parts)
local text = want_warning and '*' or msg[2] or 'Missing message'
local cat = wanted_category(msg[3], mcode[2], want_warning)
local anchor = msg[4] or ''
local fmtkey = ispreview() and 'cvt_format_preview' or
(want_warning and 'cvt_format2' or msg.format or 'cvt_format')
local fmt = text_code.all_messages[fmtkey] or 'convert: bug'
return subparm(fmt, title:gsub('"', '"'), text, cat, anchor)
end
return 'Convert internal error: unknown message'
end
function add_warning(parms, level, key, text1, text2) -- for forward declaration above
-- If enabled, add a warning that will be displayed after the convert result.
-- A higher level is more verbose: more kinds of warnings are displayed.
-- To reduce output noise, only the first warning is displayed.
if level <= (tonumber(config.warnings) or 1) then
if parms.warnings == nil then
parms.warnings = message(parms, { key, text1, text2 }, true)
end
end
end
local function spell_number(parms, inout, number, numerator, denominator)
-- Return result of spelling (number, numerator, denominator), or
-- return nil if spelling is not available or not supported for given text.
-- Examples (each value must be a string or nil):
-- number numerator denominator output
-- ------ --------- ----------- -------------------
-- "1.23" nil nil one point two three
-- "1" "2" "3" one and two thirds
-- nil "2" "3" two thirds
if not speller then
local function get_speller(module)
return require(module).spell_number
end
local success
success, speller = pcall(get_speller, spell_module)
if not success or type(speller) ~= 'function' then
add_warning(parms, 1, 'cvt_no_spell', 'spell')
return nil
end
end
local case
if parms.spell_upper == inout then
case = true
parms.spell_upper = nil -- only uppercase first word in a multiple unit
end
local sp = not parms.opt_sp_us
local adj = parms.opt_adjectival
return speller(number, numerator, denominator, case, sp, adj)
end
------------------------------------------------------------------------
-- BEGIN: Code required only for built-in units.
-- LATER: If need much more code, move to another module to simplify this module.
local function speed_of_sound(altitude)
-- This is for the Mach built-in unit of speed.
-- Return speed of sound in metres per second at given altitude in feet.
-- If no altitude given, use default (zero altitude = sea level).
-- Table gives speed of sound in miles per hour at various altitudes:
-- altitude = -17,499 to 402,499 feet
-- mach_table[a + 4] = s where
-- a = (altitude / 5000) rounded to nearest integer (-3 to 80)
-- s = speed of sound (mph) at that altitude
-- LATER: Should calculate result from an interpolation between the next
-- lower and higher altitudes in table, rather than rounding to nearest.
-- From: http://www.aerospaceweb.org/question/atmosphere/q0112.shtml
local mach_table = { -- a =
799.5, 787.0, 774.2, 761.207051, -- -3 to 0
748.0, 734.6, 721.0, 707.0, 692.8, 678.3, 663.5, 660.1, 660.1, 660.1, -- 1 to 10
660.1, 660.1, 660.1, 662.0, 664.3, 666.5, 668.9, 671.1, 673.4, 675.6, -- 11 to 20
677.9, 683.7, 689.9, 696.0, 702.1, 708.1, 714.0, 719.9, 725.8, 731.6, -- 21 to 30
737.3, 737.7, 737.7, 736.2, 730.5, 724.6, 718.8, 712.9, 707.0, 701.0, -- 31 to 40
695.0, 688.9, 682.8, 676.6, 670.4, 664.1, 657.8, 652.9, 648.3, 643.7, -- 41 to 50
639.1, 634.4, 629.6, 624.8, 620.0, 615.2, 613.2, 613.2, 613.2, 613.5, -- 51 to 60
614.4, 615.3, 616.7, 619.8, 623.4, 629.7, 635.0, 641.1, 650.6, 660.0, -- 61 to 70
672.5, 674.3, 676.1, 677.9, 679.7, 681.5, 683.3, 685.1, 686.8, 688.6, -- 71 to 80
}
altitude = altitude or 0
local a = (altitude < 0) and -altitude or altitude
a = floor(a / 5000 + 0.5)
if altitude < 0 then
a = -a
end
if a < -3 then
a = -3
elseif a > 80 then
a = 80
end
return mach_table[a + 4] * 0.44704 -- mph converted to m/s
end
-- END: Code required only for built-in units.
------------------------------------------------------------------------
local function add_style(parms, class)
-- Add selected template style to parms if not already present.
parms.templatestyles = parms.templatestyles or {}
if not parms.templatestyles[class] then
parms.templatestyles[class] = parms.frame:extensionTag({
name = 'templatestyles', args = { src = text_code.titles[class] }
})
end
end
local function get_styles(parms)
-- Return string of required template styles, empty if none.
if parms.templatestyles then
local t = {}
for _, v in pairs(parms.templatestyles) do
table.insert(t, v)
end
return table.concat(t)
end
return ''
end
local function get_range(word)
-- Return a range (string or table) corresponding to word (like "to"),
-- or return nil if not a range word.
local ranges = text_code.ranges
return ranges.types[word] or ranges.types[ranges.aliases[word]]
end
local function check_mismatch(unit1, unit2)
-- If unit1 cannot be converted to unit2, return an error message table.
-- This allows conversion between units of the same type, and between
-- Nm (normally torque) and ftlb (energy), as in gun-related articles.
-- This works because Nm is the base unit (scale = 1) for both the
-- primary type (torque), and the alternate type (energy, where Nm = J).
-- A match occurs if the primary types are the same, or if unit1 matches
-- the alternate type of unit2, and vice versa. That provides a whitelist
-- of which conversions are permitted between normally incompatible types.
if unit1.utype == unit2.utype or
(unit1.utype == unit2.alttype and unit1.alttype == unit2.utype) then
return nil
end
return { 'cvt_mismatch', unit1.utype, unit2.utype }
end
local function override_from(out_table, in_table, fields)
-- Copy the specified fields from in_table to out_table, but do not
-- copy nil fields (keep any corresponding field in out_table).
for _, field in ipairs(fields) do
if in_table[field] then
out_table[field] = in_table[field]
end
end
end
local function shallow_copy(t)
-- Return a shallow copy of table t.
-- Do not need the features and overhead of the Scribunto mw.clone().
local result = {}
for k, v in pairs(t) do
result[k] = v
end
return result
end
local unit_mt = {
-- Metatable to get missing values for a unit that does not accept SI prefixes.
-- Warning: The boolean value 'false' is returned for any missing field
-- so __index is not called twice for the same field in a given unit.
__index = function (self, key)
local value
if key == 'name1' or key == 'sym_us' then
value = self.symbol
elseif key == 'name2' then
value = self.name1 .. plural_suffix
elseif key == 'name1_us' then
value = self.name1
if not rawget(self, 'name2_us') then
-- If name1_us is 'foot', do not make name2_us by appending plural_suffix.
self.name2_us = self.name2
end
elseif key == 'name2_us' then
local raw1_us = rawget(self, 'name1_us')
if raw1_us then
value = raw1_us .. plural_suffix
else
value = self.name2
end
elseif key == 'link' then
value = self.name1
else
value = false
end
rawset(self, key, value)
return value
end
}
local function prefixed_name(unit, name, index)
-- Return unit name with SI prefix inserted at correct position.
-- index = 1 (name1), 2 (name2), 3 (name1_us), 4 (name2_us).
-- The position is a byte (not character) index, so use Lua's sub().
local pos = rawget(unit, 'prefix_position')
if type(pos) == 'string' then
pos = tonumber(split(pos, ',')[index])
end
if pos then
return name:sub(1, pos - 1) .. unit.si_name .. name:sub(pos)
end
return unit.si_name .. name
end
local unit_prefixed_mt = {
-- Metatable to get missing values for a unit that accepts SI prefixes.
-- Before use, fields si_name, si_prefix must be defined.
-- The unit must define _symbol, _name1 and
-- may define _sym_us, _name1_us, _name2_us
-- (_sym_us, _name2_us may be defined for a language using sp=us
-- to refer to a variant unrelated to U.S. units).
__index = function (self, key)
local value
if key == 'symbol' then
value = self.si_prefix .. self._symbol
if value == 'l' then value = 'L' end
elseif key == 'sym_us' then
value = rawget(self, '_sym_us')
if value then
value = self.si_prefix .. value
else
value = self.symbol
end
elseif key == 'name1' then
value = prefixed_name(self, self._name1, 1)
elseif key == 'name2' then
value = rawget(self, '_name2')
if value then
value = prefixed_name(self, value, 2)
else
value = self.name1 .. plural_suffix
end
elseif key == 'name1_us' then
value = rawget(self, '_name1_us')
if value then
value = prefixed_name(self, value, 3)
else
value = self.name1
end
elseif key == 'name2_us' then
value = rawget(self, '_name2_us')
if value then
value = prefixed_name(self, value, 4)
elseif rawget(self, '_name1_us') then
value = self.name1_us .. plural_suffix
else
value = self.name2
end
elseif key == 'link' then
value = self.name1
else
value = false
end
rawset(self, key, value)
return value
end
}
local unit_per_mt = {
-- Metatable to get values for a per unit of form "x/y".
-- This is never called to determine a unit name or link because per units
-- are handled as a special case.
-- Similarly, the default output is handled elsewhere, and for a symbol
-- this is only called from get_default() for default_exceptions.
__index = function (self, key)
local value
if key == 'symbol' then
local per = self.per
local unit1, unit2 = per[1], per[2]
if unit1 then
value = unit1[key] .. '/' .. unit2[key]
else
value = '/' .. unit2[key]
end
elseif key == 'sym_us' then
value = self.symbol
elseif key == 'scale' then
local per = self.per
local unit1, unit2 = per[1], per[2]
value = (unit1 and unit1.scale or 1) * self.scalemultiplier / unit2.scale
else
value = false
end
rawset(self, key, value)
return value
end
}
local function make_per(unitcode, unit_table, ulookup)
-- Return true, t where t is a per unit with unit codes expanded to unit tables,
-- or return false, t where t is an error message table.
local result = {
unitcode = unitcode,
utype = unit_table.utype,
per = {}
}
override_from(result, unit_table, { 'invert', 'iscomplex', 'default', 'link', 'symbol', 'symlink' })
result.symbol_raw = (result.symbol or false) -- to distinguish between a defined exception and a metatable calculation
local prefix
for i, v in ipairs(unit_table.per) do
if i == 1 and v == '' then
-- First unit symbol can be empty; that gives a nil first unit table.
elseif i == 1 and text_code.currency[v] then
prefix = currency_text or v
else
local success, t = ulookup(v)
if not success then return false, t end
result.per[i] = t
end
end
local multiplier = unit_table.multiplier
if not result.utype then
-- Creating an automatic per unit.
local unit1 = result.per[1]
local utype = (unit1 and unit1.utype or prefix or '') .. '/' .. result.per[2].utype
local t = data_code.per_unit_fixups[utype]
if t then
if type(t) == 'table' then
utype = t.utype or utype
result.link = result.link or t.link
multiplier = multiplier or t.multiplier
else
utype = t
end
end
result.utype = utype
end
result.scalemultiplier = multiplier or 1
result.vprefix = prefix or false -- set to non-nil to avoid calling __index
return true, setmetatable(result, unit_per_mt)
end
local function lookup(parms, unitcode, what, utable, fails, depth)
-- Return true, t where t is a copy of the unit's converter table,
-- or return false, t where t is an error message table.
-- Parameter 'what' determines whether combination units are accepted:
-- 'no_combination' : single unit only
-- 'any_combination' : single unit or combination or output multiple
-- 'only_multiple' : single unit or output multiple only
-- Parameter unitcode is a symbol (like 'g'), with an optional SI prefix (like 'kg').
-- If, for example, 'kg' is in this table, that entry is used;
-- otherwise the prefix ('k') is applied to the base unit ('g').
-- If unitcode is a known combination code (and if allowed by what),
-- a table of output multiple unit tables is included in the result.
-- For compatibility with the old template, an underscore in a unitcode is
-- replaced with a space so usage like {{convert|350|board_feet}} works.
-- Wikignomes may also put two spaces or " " in combinations, so
-- replace underscore, " ", and multiple spaces with a single space.
utable = utable or parms.unittable or all_units
fails = fails or {}
depth = depth and depth + 1 or 1
if depth > 9 then
-- There are ways to mistakenly define units which result in infinite
-- recursion when lookup() is called. That gives a long delay and very
-- confusing error messages, so the depth parameter is used as a guard.
return false, { 'cvt_lookup', unitcode }
end
if unitcode == nil or unitcode == '' then
return false, { 'cvt_no_unit' }
end
unitcode = unitcode:gsub('_', ' '):gsub(' ', ' '):gsub(' +', ' ')
local function call_make_per(t)
return make_per(unitcode, t,
function (ucode) return lookup(parms, ucode, 'no_combination', utable, fails, depth) end
)
end
local t = utable[unitcode]
if t then
if t.shouldbe then
return false, { 'cvt_should_be', t.shouldbe }
end
if t.sp_us then
parms.opt_sp_us = true
end
local target = t.target -- nil, or unitcode is an alias for this target
if target then
local success, result = lookup(parms, target, what, utable, fails, depth)
if not success then return false, result end
override_from(result, t, { 'customary', 'default', 'link', 'symbol', 'symlink' })
local multiplier = t.multiplier
if multiplier then
result.multiplier = tostring(multiplier)
result.scale = result.scale * multiplier
end
return true, result
end
if t.per then
return call_make_per(t)
end
local combo = t.combination -- nil or a table of unitcodes
if combo then
local multiple = t.multiple
if what == 'no_combination' or (what == 'only_multiple' and not multiple) then
return false, { 'cvt_bad_unit', unitcode }
end
-- Recursively create a combination table containing the
-- converter table of each unitcode.
local result = { utype = t.utype, multiple = multiple, combination = {} }
local cvt = result.combination
for i, v in ipairs(combo) do
local success, t = lookup(parms, v, multiple and 'no_combination' or 'only_multiple', utable, fails, depth)
if not success then return false, t end
cvt[i] = t
end
return true, result
end
local result = shallow_copy(t)
result.unitcode = unitcode
if result.prefixes then
result.si_name = ''
result.si_prefix = ''
return true, setmetatable(result, unit_prefixed_mt)
end
return true, setmetatable(result, unit_mt)
end
local SIprefixes = text_code.SIprefixes
for plen = SIprefixes[1] or 2, 1, -1 do
-- Look for an SI prefix; should never occur with an alias.
-- Check for longer prefix first ('dam' is decametre).
-- SIprefixes[1] = prefix maximum #characters (as seen by mw.ustring.sub).
local prefix = usub(unitcode, 1, plen)
local si = SIprefixes[prefix]
if si then
local t = utable[usub(unitcode, plen+1)]
if t and t.prefixes then
local result = shallow_copy(t)
result.unitcode = unitcode
result.si_name = parms.opt_sp_us and si.name_us or si.name
result.si_prefix = si.prefix or prefix
result.scale = t.scale * 10 ^ (si.exponent * t.prefixes)
return true, setmetatable(result, unit_prefixed_mt)
end
end
end
-- Accept user-defined combinations like "acre+m2+ha" or "acre m2 ha" for output.
-- If '+' is used, each unit code can include a space, and any error is fatal.
-- If ' ' is used and if each space-separated word is a unit code, it is a combo,
-- but errors are not fatal so the unit code can be looked up as an extra unit.
local err_is_fatal
local combo = collection()
if unitcode:find('+', 1, true) then
err_is_fatal = true
for item in (unitcode .. '+'):gmatch('%s*(.-)%s*%+') do
if item ~= '' then
combo:add(item)
end
end
elseif unitcode:find('%s') then
for item in unitcode:gmatch('%S+') do
combo:add(item)
end
end
if combo.n > 1 then
local function lookup_combo()
if what == 'no_combination' or what == 'only_multiple' then
return false, { 'cvt_bad_unit', unitcode }
end
local result = { combination = {} }
local cvt = result.combination
for i, v in ipairs(combo) do
local success, t = lookup(parms, v, 'only_multiple', utable, fails, depth)
if not success then return false, t end
if i == 1 then
result.utype = t.utype
else
local mismatch = check_mismatch(result, t)
if mismatch then
return false, mismatch
end
end
cvt[i] = t
end
return true, result
end
local success, result = lookup_combo()
if success or err_is_fatal then
return success, result
end
end
-- Accept any unit with an engineering notation prefix like "e6cuft"
-- (million cubic feet), but not chained prefixes like "e3e6cuft",
-- and not if the unit is a combination or multiple,
-- and not if the unit has an offset or is a built-in.
-- Only en digits are accepted.
local exponent, baseunit = unitcode:match('^e(%d+)(.*)')
if exponent then
local engscale = text_code.eng_scales[exponent]
if engscale then
local success, result = lookup(parms, baseunit, 'no_combination', utable, fails, depth)
if success and not (result.offset or result.builtin or result.engscale) then
result.unitcode = unitcode -- 'e6cuft' not 'cuft'
result.defkey = unitcode -- key to lookup default exception
result.engscale = engscale
result.scale = result.scale * 10 ^ tonumber(exponent)
return true, result
end
end
end
-- Look for x/y; split on right-most slash to get scale correct (x/y/z is x/y per z).
local top, bottom = unitcode:match('^(.-)/([^/]+)$')
if top and not unitcode:find('e%d') then
-- If valid, create an automatic per unit for an "x/y" unit code.
-- The unitcode must not include extraneous spaces.
-- Engineering notation (apart from at start and which has been stripped before here),
-- is not supported so do not make a per unit if find text like 'e3' in unitcode.
local success, result = call_make_per({ per = {top, bottom} })
if success then
return true, result
end
end
if not parms.opt_ignore_error and not get_range(unitcode) then
-- Want the "what links here" list for the extra_module to show only cases
-- where an extra unit is used, so do not require it if invoked from {{val}}
-- or if looking up a range word which cannot be a unit.
if not extra_units then
local success, extra = pcall(function () return require(extra_module).extra_units end)
if success and type(extra) == 'table' then
extra_units = extra
end
end
if extra_units then
-- A unit in one data table might refer to a unit in the other table, so
-- switch between them, relying on fails or depth to terminate loops.
if not fails[unitcode] then
fails[unitcode] = true
local other = (utable == all_units) and extra_units or all_units
local success, result = lookup(parms, unitcode, what, other, fails, depth)
if success then
return true, result
end
end
end
end
if to_en_table then
-- At fawiki it is common to translate all digits so a unit like "km2" becomes "km۲".
local en_code = ustring.gsub(unitcode, '%d', to_en_table)
if en_code ~= unitcode then
return lookup(parms, en_code, what, utable, fails, depth)
end
end
return false, { 'cvt_unknown', unitcode }
end
local function valid_number(num)
-- Return true if num is a valid number.
-- In Scribunto (different from some standard Lua), when expressed as a string,
-- overflow or other problems are indicated with text like "inf" or "nan"
-- which are regarded as invalid here (each contains "n").
if type(num) == 'number' and tostring(num):find('n', 1, true) == nil then
return true
end
end
local function hyphenated(name, parts)
-- Return a hyphenated form of given name (for adjectival usage).
-- The name may be linked and the target of the link must not be changed.
-- Hypothetical examples:
-- [[long ton|ton]] → [[long ton|ton]] (no change)
-- [[tonne|long ton]] → [[tonne|long-ton]]
-- [[metric ton|long ton]] → [[metric ton|long-ton]]
-- [[long ton]] → [[long ton|long-ton]]
-- Input can also have multiple links in a single name like:
-- [[United States customary units|U.S.]] [[US gallon|gallon]]
-- [[mile]]s per [[United States customary units|U.S.]] [[quart]]
-- [[long ton]]s per [[short ton]]
-- Assume that links cannot be nested (never like "[[abc[[def]]ghi]]").
-- This uses a simple and efficient procedure that works for most cases.
-- Some units (if used) would require more, and can later think about
-- adding a method to handle exceptions.
-- The procedure is to replace each space with a hyphen, but
-- not a space after ')' [for "(pre-1954 US) nautical mile"], and
-- not spaces immediately before '(' or in '(...)' [for cases like
-- "British thermal unit (ISO)" and "Calorie (International Steam Table)"].
if name:find(' ', 1, true) then
if parts then
local pos
if name:sub(1, 1) == '(' then
pos = name:find(')', 1, true)
if pos then
return name:sub(1, pos+1) .. name:sub(pos+2):gsub(' ', '-')
end
elseif name:sub(-1) == ')' then
pos = name:find('(', 1, true)
if pos then
return name:sub(1, pos-2):gsub(' ', '-') .. name:sub(pos-1)
end
end
return name:gsub(' ', '-')
end
parts = collection()
for before, item, after in name:gmatch('([^[]*)(%[%[[^[]*%]%])([^[]*)') do
if item:find(' ', 1, true) then
local prefix
local plen = item:find('|', 1, true)
if plen then
prefix = item:sub(1, plen)
item = item:sub(plen + 1, -3)
else
prefix = item:sub(1, -3) .. '|'
item = item:sub(3, -3)
end
item = prefix .. hyphenated(item, parts) .. ']]'
end
parts:add(before:gsub(' ', '-') .. item .. after:gsub(' ', '-'))
end
if parts.n == 0 then
-- No link like "[[...]]" was found in the original name.
parts:add(hyphenated(name, parts))
end
return table.concat(parts)
end
return name
end
local function hyphenated_maybe(parms, want_name, sep, id, inout)
-- Return s, f where
-- s = id, possibly modified
-- f = true if hyphenated
-- Possible modifications: hyphenate; prepend '-'; append mid text.
if id == nil or id == '' then
return ''
end
local mid = (inout == (parms.opt_flip and 'out' or 'in')) and parms.mid or ''
if want_name then
if parms.opt_adjectival then
return '-' .. hyphenated(id) .. mid, true
end
if parms.opt_add_s and id:sub(-1) ~= 's' then
id = id .. 's' -- for nowiki
end
end
return sep .. id .. mid
end
local function use_minus(text)
-- Return text with Unicode minus instead of '-', if present.
if text:sub(1, 1) == '-' then
return MINUS .. text:sub(2)
end
return text
end
local function digit_groups(parms, text, method)
-- Return a numbered table of groups of digits (left-to-right, in local language).
-- Parameter method is a number or nil:
-- 3 for 3-digit grouping (default), or
-- 2 for 3-then-2 grouping (only for digits before decimal mark).
local len_right
local len_left = text:find('.', 1, true)
if len_left then
len_right = #text - len_left
len_left = len_left - 1
else
len_left = #text
end
local twos = method == 2 and len_left > 5
local groups = collection()
local run = len_left
local n
if run < 4 or (run == 4 and parms.opt_comma5) then
if parms.opt_gaps then
n = run
else
n = #text
end
elseif twos then
n = run % 2 == 0 and 1 or 2
else
n = run % 3 == 0 and 3 or run % 3
end
while run > 0 do
groups:add(n)
run = run - n
n = (twos and run > 3) and 2 or 3
end
if len_right then
if groups.n == 0 then
groups:add(0)
end
if parms.opt_gaps and len_right > 3 then
local want4 = not parms.opt_gaps3 -- true gives no gap before trailing single digit
local isfirst = true
run = len_right
while run > 0 do
n = (want4 and run == 4) and 4 or (run > 3 and 3 or run)
if isfirst then
isfirst = false
groups[groups.n] = groups[groups.n] + 1 + n
else
groups:add(n)
end
run = run - n
end
else
groups[groups.n] = groups[groups.n] + 1 + len_right
end
end
local pos = 1
for i, length in ipairs(groups) do
groups[i] = from_en(text:sub(pos, pos + length - 1))
pos = pos + length
end
return groups
end
function with_separator(parms, text) -- for forward declaration above
-- Input text is a number in en digits with optional '.' decimal mark.
-- Return an equivalent, formatted for display:
-- with a custom decimal mark instead of '.', if wanted
-- with thousand separators inserted, if wanted
-- digits in local language
-- The given text is like '123' or '123.' or '12345.6789'.
-- The text has no sign (caller inserts that later, if necessary).
-- When using gaps, they are inserted before and after the decimal mark.
-- Separators are inserted only before the decimal mark.
-- A trailing dot (as in '123.') is removed because their use appears to
-- be accidental, and such a number should be shown as '123' or '123.0'.
-- It is useful for convert to suppress the dot so, for example, '4000.'
-- is a simple way of indicating that all the digits are significant.
if text:sub(-1) == '.' then
text = text:sub(1, -2)
end
if #text < 4 or parms.opt_nocomma or numsep == '' then
return from_en(text)
end
local groups = digit_groups(parms, text, group_method)
if parms.opt_gaps then
if groups.n <= 1 then
return groups[1] or ''
end
local nowrap = '<span style="white-space: nowrap">'
local gap = '<span style="margin-left: 0.25em">'
local close = '</span>'
return nowrap .. groups[1] .. gap .. table.concat(groups, close .. gap, 2, groups.n) .. close .. close
end
return table.concat(groups, numsep)
end
-- An input value like 1.23e12 is displayed using scientific notation (1.23×10¹²).
-- That also makes the output use scientific notation, except for small values.
-- In addition, very small or very large output values use scientific notation.
-- Use format(fmtpower, significand, '10', exponent) where each argument is a string.
local fmtpower = '%s<span style="margin:0 .15em 0 .25em">×</span>%s<sup>%s</sup>'
local function with_exponent(parms, show, exponent)
-- Return wikitext to display the implied value in scientific notation.
-- Input uses en digits; output uses digits in local language.
return format(fmtpower, with_separator(parms, show), from_en('10'), use_minus(from_en(tostring(exponent))))
end
local function make_sigfig(value, sigfig)
-- Return show, exponent that are equivalent to the result of
-- converting the number 'value' (where value >= 0) to a string,
-- rounded to 'sigfig' significant figures.
-- The returned items are:
-- show: a string of digits; no sign and no dot;
-- there is an implied dot before show.
-- exponent: a number (an integer) to shift the implied dot.
-- Resulting value = tonumber('.' .. show) * 10^exponent.
-- Examples:
-- make_sigfig(23.456, 3) returns '235', 2 (.235 * 10^2).
-- make_sigfig(0.0023456, 3) returns '235', -2 (.235 * 10^-2).
-- make_sigfig(0, 3) returns '000', 1 (.000 * 10^1).
if sigfig <= 0 then
sigfig = 1
elseif sigfig > maxsigfig then
sigfig = maxsigfig
end
if value == 0 then
return string.rep('0', sigfig), 1
end
local exp, fracpart = math.modf(log10(value))
if fracpart >= 0 then
fracpart = fracpart - 1
exp = exp + 1
end
local digits = format('%.0f', 10^(fracpart + sigfig))
if #digits > sigfig then
-- Overflow (for sigfig=3: like 0.9999 rounding to "1000"; need "100").
digits = digits:sub(1, sigfig)
exp = exp + 1
end
assert(#digits == sigfig, 'Bug: rounded number has wrong length')
return digits, exp
end
-- Fraction output format.
local fracfmt = {
{ -- Like {{frac}} (fraction slash).
'<span class="frac" role="math">{SIGN}<span class="num">{NUM}</span>⁄<span class="den">{DEN}</span></span>', -- 1/2
'<span class="frac" role="math">{SIGN}{WHOLE}<span class="sr-only">+</span><span class="num">{NUM}</span>⁄<span class="den">{DEN}</span></span>', -- 1+2/3
style = 'frac',
},
{ -- Like {{sfrac}} (stacked fraction, that is, horizontal bar).
'<span class="sfrac tion" role="math">{SIGN}<span class="num">{NUM}</span><span class="sr-only">/</span><span class="den">{DEN}</span></span>', -- 1//2
'<span class="sfrac" role="math">{SIGN}{WHOLE}<span class="sr-only">+</span><span class="tion"><span class="num">{NUM}</span><span class="sr-only">/</span><span class="den">{DEN}</span></span></span>', -- 1+2//3
style = 'sfrac',
},
}
local function format_fraction(parms, inout, negative, wholestr, numstr, denstr, do_spell, style)
-- Return wikitext for a fraction, possibly spelled.
-- Inputs use en digits and have no sign; output uses digits in local language.
local wikitext
if not style then
style = parms.opt_fraction_horizontal and 2 or 1
end
if wholestr == '' then
wholestr = nil
end
local substitute = {
SIGN = negative and MINUS or '',
WHOLE = wholestr and with_separator(parms, wholestr),
NUM = from_en(numstr),
DEN = from_en(denstr),
}
wikitext = fracfmt[style][wholestr and 2 or 1]:gsub('{(%u+)}', substitute)
if do_spell then
if negative then
if wholestr then
wholestr = '-' .. wholestr
else
numstr = '-' .. numstr
end
end
local s = spell_number(parms, inout, wholestr, numstr, denstr)
if s then
return s
end
end
add_style(parms, fracfmt[style].style)
return wikitext
end
local function format_number(parms, show, exponent, isnegative)
-- Parameter show is a string or a table containing strings.
-- Each string is a formatted number in en digits and optional '.' decimal mark.
-- A table represents a fraction: integer, numerator, denominator;
-- if a table is given, exponent must be nil.
-- Return t where t is a table with fields:
-- show = wikitext formatted to display implied value
-- (digits in local language)
-- is_scientific = true if show uses scientific notation
-- clean = unformatted show (possibly adjusted and with inserted '.')
-- (en digits)
-- sign = '' or MINUS
-- exponent = exponent (possibly adjusted)
-- The clean and exponent fields can be used to calculate the
-- rounded absolute value, if needed.
--
-- The value implied by the arguments is found from:
-- exponent is nil; and
-- show is a string of digits (no sign), with an optional dot;
-- show = '123.4' is value 123.4, '1234' is value 1234.0;
-- or:
-- exponent is an integer indicating where dot should be;
-- show is a string of digits (no sign and no dot);
-- there is an implied dot before show;
-- show does not start with '0';
-- show = '1234', exponent = 3 is value 0.1234*10^3 = 123.4.
--
-- The formatted result:
-- * Is for an output value and is spelled if wanted and possible.
-- * Includes a Unicode minus if isnegative and not spelled.
-- * Uses a custom decimal mark, if wanted.
-- * Has digits grouped where necessary, if wanted.
-- * Uses scientific notation if requested, or for very small or large values
-- (which forces result to not be spelled).
-- * Has no more than maxsigfig significant digits
-- (same as old template and {{#expr}}).
local xhi, xlo -- these control when scientific notation (exponent) is used
if parms.opt_scientific then
xhi, xlo = 4, 2 -- default for output if input uses e-notation
elseif parms.opt_scientific_always then
xhi, xlo = 0, 0 -- always use scientific notation (experimental)
else
xhi, xlo = 10, 4 -- default
end
local sign = isnegative and MINUS or ''
local maxlen = maxsigfig
local tfrac
if type(show) == 'table' then
tfrac = show
show = tfrac.wholestr
assert(exponent == nil, 'Bug: exponent given with fraction')
end
if not tfrac and not exponent then
local integer, dot, decimals = show:match('^(%d*)(%.?)(.*)')
if integer == '0' or integer == '' then
local zeros, figs = decimals:match('^(0*)([^0]?.*)')
if #figs == 0 then
if #zeros > maxlen then
show = '0.' .. zeros:sub(1, maxlen)
end
elseif #zeros >= xlo then
show = figs
exponent = -#zeros
elseif #figs > maxlen then
show = '0.' .. zeros .. figs:sub(1, maxlen)
end
elseif #integer >= xhi then
show = integer .. decimals
exponent = #integer
else
maxlen = maxlen + #dot
if #show > maxlen then
show = show:sub(1, maxlen)
end
end
end
if exponent then
local function zeros(n)
return string.rep('0', n)
end
if #show > maxlen then
show = show:sub(1, maxlen)
end
if exponent > xhi or exponent <= -xlo or (exponent == xhi and show ~= '1' .. zeros(xhi - 1)) then
-- When xhi, xlo = 10, 4 (the default), scientific notation is used if the
-- rounded value satisfies: value >= 1e9 or value < 1e-4 (1e9 = 0.1e10),
-- except if show is '1000000000' (1e9), for example:
-- {{convert|1000000000|m|m|sigfig=10}} → 1,000,000,000 metres (1,000,000,000 m)
local significand
if #show > 1 then
significand = show:sub(1, 1) .. '.' .. show:sub(2)
else
significand = show
end
return {
clean = '.' .. show,
exponent = exponent,
sign = sign,
show = sign .. with_exponent(parms, significand, exponent-1),
is_scientific = true,
}
end
if exponent >= #show then
show = show .. zeros(exponent - #show) -- result has no dot
elseif exponent <= 0 then
show = '0.' .. zeros(-exponent) .. show
else
show = show:sub(1, exponent) .. '.' .. show:sub(exponent+1)
end
end
local formatted_show
if tfrac then
show = tostring(tfrac.value) -- to set clean in returned table
formatted_show = format_fraction(parms, 'out', isnegative, tfrac.wholestr, tfrac.numstr, tfrac.denstr, parms.opt_spell_out)
else
if isnegative and show:match('^0.?0*$') then
sign = '' -- don't show minus if result is negative but rounds to zero
end
formatted_show = sign .. with_separator(parms, show)
if parms.opt_spell_out then
formatted_show = spell_number(parms, 'out', sign .. show) or formatted_show
end
end
return {
clean = show,
sign = sign,
show = formatted_show,
is_scientific = false, -- to avoid calling __index
}
end
local function extract_fraction(parms, text, negative)
-- If text represents a fraction, return
-- value, altvalue, show, denominator
-- where
-- value is a number (value of the fraction in argument text)
-- altvalue is an alternate interpretation of any fraction for the hands
-- unit where "12.1+3/4" means 12 hands 1.75 inches
-- show is a string (formatted text for display of an input value,
-- and is spelled if wanted and possible)
-- denominator is value of the denominator in the fraction
-- Otherwise, return nil.
-- Input uses en digits and '.' decimal mark (input has been translated).
-- Output uses digits in local language and local decimal mark, if any.
------------------------------------------------------------------------
-- Originally this function accepted x+y/z where x, y, z were any valid
-- numbers, possibly with a sign. For example '1.23e+2+1.2/2.4' = 123.5,
-- and '2-3/8' = 1.625. However, such usages were found to be errors or
-- misunderstandings, so since August 2014 the following restrictions apply:
-- x (if present) is an integer or has a single digit after decimal mark
-- y and z are unsigned integers
-- e-notation is not accepted
-- The overall number can start with '+' or '-' (so '12+3/4' and '+12+3/4'
-- and '-12-3/4' are valid).
-- Any leading negative sign is removed by the caller, so only inputs
-- like the following are accepted here (may have whitespace):
-- negative = false false true (there was a leading '-')
-- text = '2/3' '+2/3' '2/3'
-- text = '1+2/3' '+1+2/3' '1-2/3'
-- text = '12.3+1/2' '+12.3+1/2' '12.3-1/2'
-- Values like '12.3+1/2' are accepted, but are intended only for use
-- with the hands unit (not worth adding code to enforce that).
------------------------------------------------------------------------
local leading_plus, prefix, numstr, slashes, denstr =
text:match('^%s*(%+?)%s*(.-)%s*(%d+)%s*(/+)%s*(%d+)%s*$')
if not leading_plus then
-- Accept a single U+2044 fraction slash because that may be pasted.
leading_plus, prefix, numstr, denstr =
text:match('^%s*(%+?)%s*(.-)%s*(%d+)%s*⁄%s*(%d+)%s*$')
slashes = '/'
end
local numerator = tonumber(numstr)
local denominator = tonumber(denstr)
if numerator == nil or denominator == nil or (negative and leading_plus ~= '') then
return nil
end
local whole, wholestr
if prefix == '' then
wholestr = ''
whole = 0
else
-- Any prefix must be like '12+' or '12-' (whole number and fraction sign);
-- '12.3+' and '12.3-' are also accepted (single digit after decimal point)
-- because '12.3+1/2 hands' is valid (12 hands 3½ inches).
local num1, num2, frac_sign = prefix:match('^(%d+)(%.?%d?)%s*([+%-])$')
if num1 == nil then return nil end
if num2 == '' then -- num2 must be '' or like '.1' but not '.' or '.12'
wholestr = num1
else
if #num2 ~= 2 then return nil end
wholestr = num1 .. num2
end
if frac_sign ~= (negative and '-' or '+') then return nil end
whole = tonumber(wholestr)
if whole == nil then return nil end
end
local value = whole + numerator / denominator
if not valid_number(value) then return nil end
local altvalue = whole + numerator / (denominator * 10)
local style = #slashes -- kludge: 1 or 2 slashes can be used to select style
if style > 2 then style = 2 end
local wikitext = format_fraction(parms, 'in', negative, leading_plus .. wholestr, numstr, denstr, parms.opt_spell_in, style)
return value, altvalue, wikitext, denominator
end
local function extract_number(parms, text, another, no_fraction)
-- Return true, info if can extract a number from text,
-- where info is a table with the result,
-- or return false, t where t is an error message table.
-- Input can use en digits or digits in local language and can
-- have references at the end. Accepting references is intended
-- for use in infoboxes with a field for a value passed to convert.
-- Parameter another = true if the expected value is not the first.
-- Before processing, the input text is cleaned:
-- * Any thousand separators (valid or not) are removed.
-- * Any sign is replaced with '-' (if negative) or '' (otherwise).
-- That replaces Unicode minus with '-'.
-- If successful, the returned info table contains named fields:
-- value = a valid number
-- altvalue = a valid number, usually same as value but different
-- if fraction used (for hands unit)
-- singular = true if value is 1 or -1 (to use singular form of units)
-- clean = cleaned text with any separators and sign removed
-- (en digits and '.' decimal mark)
-- show = text formatted for output, possibly with ref strip markers
-- (digits in local language and custom decimal mark)
-- The resulting show:
-- * Is for an input value and is spelled if wanted and possible.
-- * Has a rounded value, if wanted.
-- * Has digits grouped where necessary, if wanted.
-- * If negative, a Unicode minus is used; otherwise the sign is
-- '+' (if the input text used '+'), or is '' (if no sign in input).
text = strip(text or '')
local reference
local pos = text:find('\127', 1, true)
if pos then
local before = text:sub(1, pos - 1)
local remainder = text:sub(pos)
local refs = {}
while #remainder > 0 do
local ref, spaces
ref, spaces, remainder = remainder:match('^(\127[^\127]*UNIQ[^\127]*%-ref[^\127]*\127)(%s*)(.*)')
if ref then
table.insert(refs, ref)
else
refs = {}
break
end
end
if #refs > 0 then
text = strip(before)
reference = table.concat(refs)
end
end
local clean = to_en(text, parms)
if clean == '' then
return false, { another and 'cvt_no_num2' or 'cvt_no_num' }
end
local isnegative, propersign = false, '' -- most common case
local singular, show, denominator
local value = tonumber(clean)
local altvalue
if value then
local sign = clean:sub(1, 1)
if sign == '+' or sign == '-' then
propersign = (sign == '+') and '+' or MINUS
clean = clean:sub(2)
end
if value < 0 then
isnegative = true
value = -value
end
else
local valstr
for _, prefix in ipairs({ '-', MINUS, '−' }) do
-- Including '-' sets isnegative in case input is a fraction like '-2-3/4'.
local plen = #prefix
if clean:sub(1, plen) == prefix then
valstr = clean:sub(plen + 1)
if valstr:match('^%s') then -- "- 1" is invalid but "-1 - 1/2" is ok
return false, { 'cvt_bad_num', text }
end
break
end
end
if valstr then
isnegative = true
propersign = MINUS
clean = valstr
value = tonumber(clean)
end
if value == nil then
if not no_fraction then
value, altvalue, show, denominator = extract_fraction(parms, clean, isnegative)
end
if value == nil then
return false, { 'cvt_bad_num', text }
end
if value <= 1 then
singular = true -- for example, "½ mile" or "one half mile" (singular unit)
end
end
end
if not valid_number(value) then -- for example, "1e310" may overflow
return false, { 'cvt_invalid_num' }
end
if show == nil then
-- clean is a non-empty string with no spaces, and does not represent a fraction,
-- and value = tonumber(clean) is a number >= 0.
-- If the input uses e-notation, show will be displayed using a power of ten, but
-- we use the number as given so it might not be normalized scientific notation.
-- The input value is spelled if specified so any e-notation is ignored;
-- that allows input like 2e6 to be spelled as "two million" which works
-- because the spell module converts '2e6' to '2000000' before spelling.
local function rounded(value, default, exponent)
local precision = parms.opt_ri
if precision then
local fmt = '%.' .. format('%d', precision) .. 'f'
local result = fmt:format(tonumber(value) + 2e-14) -- fudge for some common cases of bad rounding
if not exponent then
singular = (tonumber(result) == 1)
end
return result
end
return default
end
singular = (value == 1)
local scientific
local significand, exponent = clean:match('^([%d.]+)[Ee]([+%-]?%d+)')
if significand then
show = with_exponent(parms, rounded(significand, significand, exponent), exponent)
scientific = true
else
show = with_separator(parms, rounded(value, clean))
end
show = propersign .. show
if parms.opt_spell_in then
show = spell_number(parms, 'in', propersign .. rounded(value, clean)) or show
scientific = false
end
if scientific then
parms.opt_scientific = true
end
end
if isnegative and (value ~= 0) then
value = -value
altvalue = -(altvalue or value)
end
return true, {
value = value,
altvalue = altvalue or value,
singular = singular,
clean = clean,
show = show .. (reference or ''),
denominator = denominator,
}
end
local function get_number(text)
-- Return v, f where:
-- v = nil (text is not a number)
-- or
-- v = value of text (text is a number)
-- f = true if value is an integer
-- Input can use en digits or digits in local language or separators,
-- but no Unicode minus, and no fraction.
if text then
local number = tonumber(to_en(text))
if number then
local _, fracpart = math.modf(number)
return number, (fracpart == 0)
end
end
end
local function gcd(a, b)
-- Return the greatest common denominator for the given values,
-- which are known to be positive integers.
if a > b then
a, b = b, a
end
if a <= 0 then
return b
end
local r = b % a
if r <= 0 then
return a
end
if r == 1 then
return 1
end
return gcd(r, a)
end
local function fraction_table(value, denominator)
-- Return value as a string or a table:
-- * If result is a string, there is no fraction, and the result
-- is value formatted as a string of en digits.
-- * If result is a table, it represents a fraction with named fields:
-- wholestr, numstr, denstr (strings of en digits for integer, numerator, denominator).
-- The result is rounded to the nearest multiple of (1/denominator).
-- If the multiple is zero, no fraction is included.
-- No fraction is included if value is very large as the fraction would
-- be unhelpful, particularly if scientific notation is required.
-- Input value is a non-negative number.
-- Input denominator is a positive integer for the desired fraction.
if value <= 0 then
return '0'
end
if denominator <= 0 or value > 1e8 then
return format('%.2f', value)
end
local integer, decimals = math.modf(value)
local numerator = floor((decimals * denominator) +
0.5 + 2e-14) -- add fudge for some common cases of bad rounding
if numerator >= denominator then
integer = integer + 1
numerator = 0
end
local wholestr = tostring(integer)
if numerator > 0 then
local div = gcd(numerator, denominator)
if div > 1 then
numerator = numerator / div
denominator = denominator / div
end
return {
wholestr = (integer > 0) and wholestr or '',
numstr = tostring(numerator),
denstr = tostring(denominator),
value = value,
}
end
return wholestr
end
local function preunits(count, preunit1, preunit2)
-- If count is 1:
-- ignore preunit2
-- return p1
-- else:
-- preunit1 is used for preunit2 if the latter is empty
-- return p1, p2
-- where:
-- p1 is text to insert before the input unit
-- p2 is text to insert before the output unit
-- p1 or p2 may be nil to mean "no preunit"
-- Using '+' gives output like "5+ feet" (no space before, but space after).
local function withspace(text, wantboth)
-- Return text with space before and, if wantboth, after.
-- However, no space is added if there is a space or ' ' or '-'
-- at that position ('-' is for adjectival text).
-- There is also no space if text starts with '&'
-- (e.g. '°' would display a degree symbol with no preceding space).
local char = text:sub(1, 1)
if char == '&' then
return text -- an html entity can be used to specify the exact display
end
if not (char == ' ' or char == '-' or char == '+') then
text = ' ' .. text
end
if wantboth then
char = text:sub(-1, -1)
if not (char == ' ' or char == '-' or text:sub(-6, -1) == ' ') then
text = text .. ' '
end
end
return text
end
local PLUS = '+ '
preunit1 = preunit1 or ''
local trim1 = strip(preunit1)
if count == 1 then
if trim1 == '' then
return nil
end
if trim1 == '+' then
return PLUS
end
return withspace(preunit1, true)
end
preunit1 = withspace(preunit1)
preunit2 = preunit2 or ''
local trim2 = strip(preunit2)
if trim1 == '+' then
if trim2 == '' or trim2 == '+' then
return PLUS, PLUS
end
preunit1 = PLUS
end
if trim2 == '' then
if trim1 == '' then
return nil, nil
end
preunit2 = preunit1
elseif trim2 == '+' then
preunit2 = PLUS
elseif trim2 == ' ' then -- trick to make preunit2 empty
preunit2 = nil
else
preunit2 = withspace(preunit2)
end
return preunit1, preunit2
end
local function range_text(range, want_name, parms, before, after, inout, options)
-- Return before .. rtext .. after
-- where rtext is the text that separates two values in a range.
local rtext, adj_text, exception
options = options or {}
if type(range) == 'table' then
-- Table must specify range text for ('off' and 'on') or ('input' and 'output'),
-- and may specify range text for 'adj=on',
-- and may specify exception = true.
rtext = range[want_name and 'off' or 'on'] or
range[((inout == 'in') == (parms.opt_flip == true)) and 'output' or 'input']
adj_text = range['adj']
exception = range['exception']
else
rtext = range
end
if parms.opt_adjectival then
if want_name or (exception and parms.abbr_org == 'on') then
rtext = adj_text or rtext:gsub(' ', '-'):gsub(' ', '-')
end
end
if rtext == '–' and (options.spaced or after:sub(1, #MINUS) == MINUS) then
rtext = ' – '
end
return before .. rtext .. after
end
local function get_composite(parms, iparm, in_unit_table)
-- Look for a composite input unit. For example, {{convert|1|yd|2|ft|3|in}}
-- would result in a call to this function with
-- iparm = 3 (parms[iparm] = "2", just after the first unit)
-- in_unit_table = (unit table for "yd"; contains value 1 for number of yards)
-- Return true, iparm, unit where
-- iparm = index just after the composite units (7 in above example)
-- unit = composite unit table holding all input units,
-- or return true if no composite unit is present in parms,
-- or return false, t where t is an error message table.
local default, subinfo
local composite_units, count = { in_unit_table }, 1
local fixups = {}
local total = in_unit_table.valinfo[1].value
local subunit = in_unit_table
while subunit.subdivs do -- subdivs is nil or a table of allowed subdivisions
local subcode = strip(parms[iparm+1])
local subdiv = subunit.subdivs[subcode] or subunit.subdivs[(all_units[subcode] or {}).target]
if not subdiv then
break
end
local success
success, subunit = lookup(parms, subcode, 'no_combination')
if not success then return false, subunit end -- should never occur
success, subinfo = extract_number(parms, parms[iparm])
if not success then return false, subinfo end
iparm = iparm + 2
subunit.inout = 'in'
subunit.valinfo = { subinfo }
-- Recalculate total as a number of subdivisions.
-- subdiv[1] = number of subdivisions per previous unit (integer > 1).
total = total * subdiv[1] + subinfo.value
if not default then -- set by the first subdiv with a default defined
default = subdiv.default
end
count = count + 1
composite_units[count] = subunit
if subdiv.unit or subdiv.name then
fixups[count] = { unit = subdiv.unit, name = subdiv.name, valinfo = subunit.valinfo }
end
end
if count == 1 then
return true -- no error and no composite unit
end
for i, fixup in pairs(fixups) do
local unit = fixup.unit
local name = fixup.name
if not unit or (count > 2 and name) then
composite_units[i].fixed_name = name
else
local success, alternate = lookup(parms, unit, 'no_combination')
if not success then return false, alternate end -- should never occur
alternate.inout = 'in'
alternate.valinfo = fixup.valinfo
composite_units[i] = alternate
end
end
return true, iparm, {
utype = in_unit_table.utype,
scale = subunit.scale, -- scale of last (least significant) unit
valinfo = { { value = total, clean = subinfo.clean, denominator = subinfo.denominator } },
composite = composite_units,
default = default or in_unit_table.default
}
end
local function translate_parms(parms, kv_pairs)
-- Update fields in parms by translating each key:value in kv_pairs to terms
-- used by this module (may involve translating from local language to English).
-- Also, checks are performed which may display warnings, if enabled.
-- Return true if successful or return false, t where t is an error message table.
currency_text = nil -- local testing can hold module in memory; must clear globals
if kv_pairs.adj and kv_pairs.sing then
-- For enwiki (before translation), warn if attempt to use adj and sing
-- as the latter is a deprecated alias for the former.
if kv_pairs.adj ~= kv_pairs.sing and kv_pairs.sing ~= '' then
add_warning(parms, 1, 'cvt_unknown_option', 'sing=' .. kv_pairs.sing)
end
kv_pairs.sing = nil
end
kv_pairs.comma = kv_pairs.comma or config.comma -- for plwiki who want default comma=5
for loc_name, loc_value in pairs(kv_pairs) do
local en_name = text_code.en_option_name[loc_name]
if en_name then
local en_value = text_code.en_option_value[en_name]
if en_value == 'INTEGER' then -- altitude_ft, altitude_m, frac, sigfig
en_value = nil
if loc_value == '' then
add_warning(parms, 2, 'cvt_empty_option', loc_name)
else
local minimum
local number, is_integer = get_number(loc_value)
if en_name == 'sigfig' then
minimum = 1
elseif en_name == 'frac' then
minimum = 2
if number and number < 0 then
parms.opt_fraction_horizontal = true
number = -number
end
else
minimum = -1e6
end
if number and is_integer and number >= minimum then
en_value = number
else
local m
if en_name == 'frac' then
m = 'cvt_bad_frac'
elseif en_name == 'sigfig' then
m = 'cvt_bad_sigfig'
else
m = 'cvt_bad_altitude'
end
add_warning(parms, 1, m, loc_name .. '=' .. loc_value)
end
end
elseif en_value == 'TEXT' then -- $, input, qid, qual, stylein, styleout, tracking
en_value = loc_value ~= '' and loc_value or nil -- accept non-empty user text with no validation
if not en_value and (en_name == '$' or en_name == 'qid' or en_name == 'qual') then
add_warning(parms, 2, 'cvt_empty_option', loc_name)
elseif en_name == '$' then
-- Value should be a single character like "€" for the euro currency symbol, but anything is accepted.
currency_text = (loc_value == 'euro') and '€' or loc_value
elseif en_name == 'input' then
-- May have something like {{convert|input=}} (empty input) if source is an infobox
-- with optional fields. In that case, want to output nothing rather than an error.
parms.input_text = loc_value -- keep input because parms.input is nil if loc_value == ''
end
else
en_value = en_value[loc_value]
if en_value and en_value:sub(-1) == '?' then
en_value = en_value:sub(1, -2)
add_warning(parms, -1, 'cvt_deprecated', loc_name .. '=' .. loc_value)
end
if en_value == nil then
if loc_value == '' then
add_warning(parms, 2, 'cvt_empty_option', loc_name)
else
add_warning(parms, 1, 'cvt_unknown_option', loc_name .. '=' .. loc_value)
end
elseif en_value == '' then
en_value = nil -- an ignored option like adj=off
elseif type(en_value) == 'string' and en_value:sub(1, 4) == 'opt_' then
for _, v in ipairs(split(en_value, ',')) do
local lhs, rhs = v:match('^(.-)=(.+)$')
if rhs then
parms[lhs] = tonumber(rhs) or rhs
else
parms[v] = true
end
end
en_value = nil
end
end
parms[en_name] = en_value
else
add_warning(parms, 1, 'cvt_unknown_option', loc_name .. '=' .. loc_value)
end
end
local abbr_entered = parms.abbr
local cfg_abbr = config.abbr
if cfg_abbr then
-- Don't warn if invalid because every convert would show that warning.
if cfg_abbr == 'on always' then
parms.abbr = 'on'
elseif cfg_abbr == 'off always' then
parms.abbr = 'off'
elseif parms.abbr == nil then
if cfg_abbr == 'on default' then
parms.abbr = 'on'
elseif cfg_abbr == 'off default' then
parms.abbr = 'off'
end
end
end
if parms.abbr then
if parms.abbr == 'unit' then
parms.abbr = 'on'
parms.number_word = true
end
parms.abbr_org = parms.abbr -- original abbr, before any flip
elseif parms.opt_hand_hh then
parms.abbr_org = 'on'
parms.abbr = 'on'
else
parms.abbr = 'out' -- default is to abbreviate output only (use symbol, not name)
end
if parms.opt_order_out then
-- Disable options that do not work in a useful way with order=out.
parms.opt_flip = nil -- override adj=flip
parms.opt_spell_in = nil
parms.opt_spell_out = nil
parms.opt_spell_upper = nil
end
if parms.opt_spell_out and not abbr_entered then
parms.abbr = 'off' -- should show unit name when spelling the output value
end
if parms.opt_flip then
local function swap_in_out(option)
local value = parms[option]
if value == 'in' then
parms[option] = 'out'
elseif value == 'out' then
parms[option] = 'in'
end
end
swap_in_out('abbr')
swap_in_out('lk')
if parms.opt_spell_in and not parms.opt_spell_out then
-- For simplicity, and because it does not appear to be needed,
-- user cannot set an option to spell the output only.
parms.opt_spell_in = nil
parms.opt_spell_out = true
end
end
if parms.opt_spell_upper then
parms.spell_upper = parms.opt_flip and 'out' or 'in'
end
if parms.opt_table or parms.opt_tablecen then
if abbr_entered == nil and parms.lk == nil then
parms.opt_values = true
end
parms.table_align = parms.opt_table and 'right' or 'center'
end
if parms.table_align or parms.opt_sortable_on then
parms.need_table_or_sort = true
end
local disp_joins = text_code.disp_joins
local default_joins = disp_joins['b']
parms.join_between = default_joins[3] or '; '
local disp = parms.disp
if disp == nil then -- special case for the most common setting
parms.joins = default_joins
elseif disp == 'x' then
-- Later, parms.joins is set from the input parameters.
else
-- Old template does this.
local abbr = parms.abbr
if disp == 'slash' then
if abbr_entered == nil then
disp = 'slash-nbsp'
elseif abbr == 'in' or abbr == 'out' then
disp = 'slash-sp'
else
disp = 'slash-nosp'
end
elseif disp == 'sqbr' then
if abbr == 'on' then
disp = 'sqbr-nbsp'
else
disp = 'sqbr-sp'
end
end
parms.joins = disp_joins[disp] or default_joins
parms.join_between = parms.joins[3] or parms.join_between
parms.wantname = parms.joins.wantname
end
if (en_default and not parms.opt_lang_local and (parms[1] or ''):find('%d')) or parms.opt_lang_en then
from_en_table = nil
end
if en_default and from_en_table then
-- For hiwiki: localized symbol/name is defined with the US symbol/name field,
-- and is used if output uses localized numbers.
parms.opt_sp_us = true
end
return true
end
local function get_values(parms)
-- If successful, update parms and return true, v, i where
-- v = table of input values
-- i = index to next entry in parms after those processed here
-- or return false, t where t is an error message table.
local valinfo = collection() -- numbered table of input values
local range = collection() -- numbered table of range items (having, for example, 2 range items requires 3 input values)
local had_nocomma -- true if removed "nocomma" kludge from second parameter (like "tonocomma")
local parm2 = strip(parms[2])
if parm2 and parm2:sub(-7, -1) == 'nocomma' then
parms[2] = strip(parm2:sub(1, -8))
parms.opt_nocomma = true
had_nocomma = true
end
local function extractor(i)
-- If the parameter is not a value, try unpacking it as a range ("1-23" for "1 to 23").
-- However, "-1-2/3" is a negative fraction (-1⅔), so it must be extracted first.
-- Do not unpack a parameter if it is like "3-1/2" which is sometimes incorrectly
-- used instead of "3+1/2" (and which should not be interpreted as "3 to ½").
-- Unpacked items are inserted into the parms table.
-- The tail recursion allows combinations like "1x2 to 3x4".
local valstr = strip(parms[i]) -- trim so any '-' as a negative sign will be at start
local success, result = extract_number(parms, valstr, i > 1)
if not success and valstr and i < 20 then -- check i to limit abuse
local lhs, sep, rhs = valstr:match('^(%S+)%s+(%S+)%s+(%S.*)')
if lhs and not (sep == '-' and rhs:match('/')) then
if sep:find('%d') then
return success, result -- to reject {{convert|1 234 567|m}} with a decent message (en only)
end
parms[i] = rhs
table.insert(parms, i, sep)
table.insert(parms, i, lhs)
return extractor(i)
end
if not valstr:match('%-.*/') then
for _, sep in ipairs(text_code.ranges.words) do
local start, stop = valstr:find(sep, 2, true) -- start at 2 to skip any negative sign for range '-'
if start then
parms[i] = valstr:sub(stop + 1)
table.insert(parms, i, sep)
table.insert(parms, i, valstr:sub(1, start - 1))
return extractor(i)
end
end
end
end
return success, result
end
local i = 1
local is_change
while true do
local success, info = extractor(i) -- need to set parms.opt_nocomma before calling this
if not success then return false, info end
i = i + 1
if is_change then
info.is_change = true -- value is after "±" and so is a change (significant for range like {{convert|5|±|5|°C}})
is_change = nil
end
valinfo:add(info)
local range_item = get_range(strip(parms[i]))
if not range_item then
break
end
i = i + 1
range:add(range_item)
if type(range_item) == 'table' then
-- For range "x", if append unit to some values, append it to all.
parms.in_range_x = parms.in_range_x or range_item.in_range_x
parms.out_range_x = parms.out_range_x or range_item.out_range_x
parms.abbr_range_x = parms.abbr_range_x or range_item.abbr_range_x
is_change = range_item.is_range_change
end
end
if range.n > 0 then
if range.n > 30 then -- limit abuse, although 4 is a more likely upper limit
return false, { 'cvt_invalid_num' } -- misleading message but it will do
end
parms.range = range
elseif had_nocomma then
return false, { 'cvt_unknown', parm2 }
end
return true, valinfo, i
end
local function simple_get_values(parms)
-- If input is like "{{convert|valid_value|valid_unit|...}}",
-- return true, i, in_unit, in_unit_table
-- i = index in parms of what follows valid_unit, if anything.
-- The valid_value is not negative and does not use a fraction, and
-- no options requiring further processing of the input are used.
-- Otherwise, return nothing or return false, parm1 for caller to interpret.
-- Testing shows this function is successful for 96% of converts in articles,
-- and that on average it speeds up converts by 8%.
local clean = to_en(strip(parms[1] or ''), parms)
if parms.opt_ri or parms.opt_spell_in or #clean > 10 or not clean:match('^[0-9.]+$') then
return false, clean
end
local value = tonumber(clean)
if not value then return end
local info = {
value = value,
altvalue = value,
singular = (value == 1),
clean = clean,
show = with_separator(parms, clean),
}
local in_unit = strip(parms[2])
local success, in_unit_table = lookup(parms, in_unit, 'no_combination')
if not success then return end
in_unit_table.valinfo = { info }
return true, 3, in_unit, in_unit_table
end
local function wikidata_call(parms, operation, ...)
-- Return true, s where s is the result of a Wikidata operation,
-- or return false, t where t is an error message table.
local function worker(...)
wikidata_code = wikidata_code or require(wikidata_module)
wikidata_data = wikidata_data or mw.loadData(wikidata_data_module)
return wikidata_code[operation](wikidata_data, ...)
end
local success, status, result = pcall(worker, ...)
if success then
return status, result
end
if parms.opt_sortable_debug then
-- Use debug=yes to crash if an error while accessing Wikidata.
error('Error accessing Wikidata: ' .. status, 0)
end
return false, { 'cvt_wd_fail' }
end
local function get_parms(parms, args)
-- If successful, update parms and return true, unit where
-- parms is a table of all arguments passed to the template
-- converted to named arguments, and
-- unit is the input unit table;
-- or return false, t where t is an error message table.
-- For special processing (not a convert), can also return
-- true, wikitext where wikitext is the final result.
-- The returned input unit table may be for a fake unit using the specified
-- unit code as the symbol and name, and with bad_mcode = message code table.
-- MediaWiki removes leading and trailing whitespace from the values of
-- named arguments. However, the values of numbered arguments include any
-- whitespace entered in the template, and whitespace is used by some
-- parameters (example: the numbered parameters associated with "disp=x").
local kv_pairs = {} -- table of input key:value pairs where key is a name; needed because cannot iterate parms and add new fields to it
for k, v in pairs(args) do
if type(k) == 'number' or k == 'test' then -- parameter "test" is reserved for testing and is not translated
parms[k] = v
else
kv_pairs[k] = v
end
end
if parms.test == 'wikidata' then
local ulookup = function (ucode)
-- Use empty table for parms so it does not accumulate results when used repeatedly.
return lookup({}, ucode, 'no_combination')
end
return wikidata_call(parms, '_listunits', ulookup)
end
local success, msg = translate_parms(parms, kv_pairs)
if not success then return false, msg end
if parms.input then
success, msg = wikidata_call(parms, '_adjustparameters', parms, 1)
if not success then return false, msg end
end
local success, i, in_unit, in_unit_table = simple_get_values(parms)
if not success then
if type(i) == 'string' and i:match('^NNN+$') then
-- Some infoboxes have examples like {{convert|NNN|m}} (3 or more "N").
-- Output an empty string for these.
return false, { 'cvt_no_output' }
end
local valinfo
success, valinfo, i = get_values(parms)
if not success then return false, valinfo end
in_unit = strip(parms[i])
i = i + 1
success, in_unit_table = lookup(parms, in_unit, 'no_combination')
if not success then
in_unit = in_unit or ''
if parms.opt_ignore_error then -- display given unit code with no error (for use with {{val}})
in_unit_table = '' -- suppress error message and prevent processing of output unit
end
in_unit_table = setmetatable({
symbol = in_unit, name2 = in_unit, utype = in_unit,
scale = 1, default = '', defkey = '', linkey = '',
bad_mcode = in_unit_table }, unit_mt)
end
in_unit_table.valinfo = valinfo
end
if parms.test == 'msg' then
-- Am testing the messages produced when no output unit is specified, and
-- the input unit has a missing or invalid default.
-- Set two units for testing that.
-- LATER: Remove this code.
if in_unit == 'chain' then
in_unit_table.default = nil -- no default
elseif in_unit == 'rd' then
in_unit_table.default = "ft!X!m" -- an invalid expression
end
end
in_unit_table.inout = 'in' -- this is an input unit
if not parms.range then
local success, inext, composite_unit = get_composite(parms, i, in_unit_table)
if not success then return false, inext end
if composite_unit then
in_unit_table = composite_unit
i = inext
end
end
if in_unit_table.builtin == 'mach' then
-- As with old template, a number following Mach as the input unit is the altitude.
-- That is deprecated: should use altitude_ft=NUMBER or altitude_m=NUMBER.
local success, info
success = tonumber(parms[i]) -- this will often work and will give correct result for values like 2e4 without forcing output scientific notation
if success then
info = { value = success }
else
success, info = extract_number(parms, parms[i], false, true)
end
if success then
i = i + 1
in_unit_table.altitude = info.value
end
end
local word = strip(parms[i])
i = i + 1
local precision, is_bad_precision
local function set_precision(text)
local number, is_integer = get_number(text)
if number then
if is_integer then
precision = number
else
precision = text
is_bad_precision = true
end
return true -- text was used for precision, good or bad
end
end
if word and not set_precision(word) then
parms.out_unit = parms.out_unit or word
if set_precision(strip(parms[i])) then
i = i + 1
end
end
if parms.opt_adj_mid then
word = parms[i]
i = i + 1
if word then -- mid-text words
if word:sub(1, 1) == '-' then
parms.mid = word
else
parms.mid = ' ' .. word
end
end
end
if parms.opt_one_preunit then
parms[parms.opt_flip and 'preunit2' or 'preunit1'] = preunits(1, parms[i])
i = i + 1
end
if parms.disp == 'x' then
-- Following is reasonably compatible with the old template.
local first = parms[i] or ''
local second = parms[i+1] or ''
i = i + 2
if strip(first) == '' then -- user can enter ' ' rather than ' ' to avoid the default
first = ' [ ' .. first
second = ' ]' .. second
end
parms.joins = { first, second }
elseif parms.opt_two_preunits then
local p1, p2 = preunits(2, parms[i], parms[i+1])
i = i + 2
if parms.preunit1 then
-- To simplify documentation, allow unlikely use of adj=pre with disp=preunit
-- (however, an output unit must be specified with adj=pre and with disp=preunit).
parms.preunit1 = parms.preunit1 .. p1
parms.preunit2 = p2
else
parms.preunit1, parms.preunit2 = p1, p2
end
end
if precision == nil then
if set_precision(strip(parms[i])) then
i = i + 1
end
end
if is_bad_precision then
add_warning(parms, 1, 'cvt_bad_prec', precision)
else
parms.precision = precision
end
for j = i, i + 3 do
local parm = parms[j] -- warn if find a non-empty extraneous parameter
if parm and parm:match('%S') then
add_warning(parms, 1, 'cvt_unknown_option', parm)
break
end
end
return true, in_unit_table
end
local function record_default_precision(parms, out_current, precision)
-- If necessary, adjust parameters and return a possibly adjusted precision.
-- When converting a range of values where a default precision is required,
-- that default is calculated for each value because the result sometimes
-- depends on the precise input and output values. This function may cause
-- the entire convert process to be repeated in order to ensure that the
-- same default precision is used for each individual convert.
-- If that were not done, a range like 1000 to 1000.4 may give poor results
-- because the first output could be heavily rounded, while the second is not.
-- For range 1000.4 to 1000, this function can give the second convert the
-- same default precision that was used for the first.
if not parms.opt_round_each then
local maxdef = out_current.max_default_precision
if maxdef then
if maxdef < precision then
parms.do_convert_again = true
out_current.max_default_precision = precision
else
precision = out_current.max_default_precision
end
else
out_current.max_default_precision = precision
end
end
return precision
end
local function default_precision(parms, invalue, inclean, denominator, outvalue, in_current, out_current, extra)
-- Return a default value for precision (an integer like 2, 0, -2).
-- If denominator is not nil, it is the value of the denominator in inclean.
-- Code follows procedures used in old template.
local fudge = 1e-14 -- {{Order of magnitude}} adds this, so we do too
local prec, minprec, adjust
local subunit_ignore_trailing_zero
local subunit_more_precision -- kludge for "in" used in input like "|2|ft|6|in"
local composite = in_current.composite
if composite then
subunit_ignore_trailing_zero = true -- input "|2|st|10|lb" has precision 0, not -1
if composite[#composite].exception == 'subunit_more_precision' then
subunit_more_precision = true -- do not use standard precision with input like "|2|ft|6|in"
end
end
if denominator and denominator > 0 then
prec = math.max(log10(denominator), 1)
else
-- Count digits after decimal mark, handling cases like '12.345e6'.
local exponent
local integer, dot, decimals, expstr = inclean:match('^(%d*)(%.?)(%d*)(.*)')
local e = expstr:sub(1, 1)
if e == 'e' or e == 'E' then
exponent = tonumber(expstr:sub(2))
end
if dot == '' then
prec = subunit_ignore_trailing_zero and 0 or -integer:match('0*$'):len()
else
prec = #decimals
end
if exponent then
-- So '1230' and '1.23e3' both give prec = -1, and '0.00123' and '1.23e-3' give 5.
prec = prec - exponent
end
end
if in_current.istemperature and out_current.istemperature then
-- Converting between common temperatures (°C, °F, °R, K); not keVT.
-- Kelvin value can be almost zero, or small but negative due to precision problems.
-- Also, an input value like -300 C (below absolute zero) gives negative kelvins.
-- Calculate minimum precision from absolute value.
adjust = 0
local kelvin = abs((invalue - in_current.offset) * in_current.scale)
if kelvin < 1e-8 then -- assume nonzero due to input or calculation precision problem
minprec = 2
else
minprec = 2 - floor(log10(kelvin) + fudge) -- 3 sigfigs in kelvin
end
else
if invalue == 0 or outvalue <= 0 then
-- We are never called with a negative outvalue, but it might be zero.
-- This is special-cased to avoid calculation exceptions.
return record_default_precision(parms, out_current, 0)
end
if out_current.exception == 'integer_more_precision' and floor(invalue) == invalue then
-- With certain output units that sometimes give poor results
-- with default rounding, use more precision when the input
-- value is equal to an integer. An example of a poor result
-- is when input 50 gives a smaller output than input 49.5.
-- Experiment shows this helps, but it does not eliminate all
-- surprises because it is not clear whether "50" should be
-- interpreted as "from 45 to 55" or "from 49.5 to 50.5".
adjust = -log10(in_current.scale)
elseif subunit_more_precision then
-- Conversion like "{{convert|6|ft|1|in|cm}}" (where subunit is "in")
-- has a non-standard adjust value, to give more output precision.
adjust = log10(out_current.scale) + 2
else
adjust = log10(abs(invalue / outvalue))
end
adjust = adjust + log10(2)
-- Ensure that the output has at least two significant figures.
minprec = 1 - floor(log10(outvalue) + fudge)
end
if extra then
adjust = extra.adjust or adjust
minprec = extra.minprec or minprec
end
return record_default_precision(parms, out_current, math.max(floor(prec + adjust), minprec))
end
local function convert(parms, invalue, info, in_current, out_current)
-- Convert given input value from one unit to another.
-- Return output_value (a number) if a simple convert, or
-- return f, t where
-- f = true, t = table of information with results, or
-- f = false, t = error message table.
local inscale = in_current.scale
local outscale = out_current.scale
if not in_current.iscomplex and not out_current.iscomplex then
return invalue * (inscale / outscale) -- minimize overhead for most common case
end
if in_current.invert or out_current.invert then
-- Inverted units, such as inverse length, inverse time, or
-- fuel efficiency. Built-in units do not have invert set.
if (in_current.invert or 1) * (out_current.invert or 1) < 0 then
return 1 / (invalue * inscale * outscale)
end
return invalue * (inscale / outscale)
elseif in_current.offset then
-- Temperature (there are no built-ins for this type of unit).
if info.is_change then
return invalue * (inscale / outscale)
end
return (invalue - in_current.offset) * (inscale / outscale) + out_current.offset
else
-- Built-in unit.
local in_builtin = in_current.builtin
local out_builtin = out_current.builtin
if in_builtin and out_builtin then
if in_builtin == out_builtin then
return invalue
end
-- There are no cases (yet) where need to convert from one
-- built-in unit to another, so this should never occur.
return false, { 'cvt_bug_convert' }
end
if in_builtin == 'mach' or out_builtin == 'mach' then
-- Should check that only one altitude is given but am planning to remove
-- in_current.altitude (which can only occur when Mach is the input unit),
-- and out_current.altitude cannot occur.
local alt = parms.altitude_ft or in_current.altitude
if not alt and parms.altitude_m then
alt = parms.altitude_m / 0.3048 -- 1 ft = 0.3048 m
end
local spd = speed_of_sound(alt)
if in_builtin == 'mach' then
inscale = spd
return invalue * (inscale / outscale)
end
outscale = spd
local adjust = 0.1 / inscale
return true, {
outvalue = invalue * (inscale / outscale),
adjust = log10(adjust) + log10(2),
}
elseif in_builtin == 'hand' then
-- 1 hand = 4 inches; 1.2 hands = 6 inches.
-- Decimals of a hand are only defined for the first digit, and
-- the first fractional digit should be a number of inches (1, 2 or 3).
-- However, this code interprets the entire fractional part as the number
-- of inches / 10 (so 1.75 inches would be 0.175 hands).
-- A value like 12.3 hands is exactly 12*4 + 3 inches; base default precision on that.
local integer, fracpart = math.modf(invalue)
local inch_value = 4 * integer + 10 * fracpart -- equivalent number of inches
local factor = inscale / outscale
if factor == 4 then
-- Am converting to inches: show exact result, and use "inches" not "in" by default.
if parms.abbr_org == nil then
out_current.usename = true
end
local show = format('%g', abs(inch_value)) -- show and clean are unsigned
if not show:find('e', 1, true) then
return true, {
invalue = inch_value,
outvalue = inch_value,
clean = show,
show = show,
}
end
end
local outvalue = (integer + 2.5 * fracpart) * factor
local fracstr = info.clean:match('%.(.*)') or ''
local fmt
if fracstr == '' then
fmt = '%.0f'
else
fmt = '%.' .. format('%d', #fracstr - 1) .. 'f'
end
return true, {
invalue = inch_value,
clean = format(fmt, inch_value),
outvalue = outvalue,
minprec = 0,
}
end
end
return false, { 'cvt_bug_convert' } -- should never occur
end
local function user_style(parms, i)
-- Return text for a user-specified style for a table cell, or '' if none,
-- given i = 1 (input style) or 2 (output style).
local style = parms[(i == 1) and 'stylein' or 'styleout']
if style then
style = style:gsub('"', '')
if style ~= '' then
if style:sub(-1) ~= ';' then
style = style .. ';'
end
return style
end
end
return ''
end
local function make_table_or_sort(parms, invalue, info, in_current, scaled_top)
-- Set options to handle output for a table or a sort key, or both.
-- The text sort key is based on the value resulting from converting
-- the input to a fake base unit with scale = 1, and other properties
-- required for a conversion derived from the input unit.
-- For other modules, return the sort key in a hidden span element, and
-- the scaled value used to generate the sort key.
-- If scaled_top is set, it is the scaled value of the numerator of a per unit
-- to be combined with this unit (the denominator) to make the sort key.
-- Scaling only works with units that convert with a factor (not temperature).
local sortkey, scaled_value
if parms.opt_sortable_on then
local base = { -- a fake unit with enough fields for a valid convert
scale = 1,
invert = in_current.invert and 1,
iscomplex = in_current.iscomplex,
offset = in_current.offset and 0,
}
local outvalue, extra = convert(parms, invalue, info, in_current, base)
if extra then
outvalue = extra.outvalue
end
if in_current.istemperature then
-- Have converted to kelvin; assume numbers close to zero have a
-- rounding error and should be zero.
if abs(outvalue) < 1e-12 then
outvalue = 0
end
end
if scaled_top and outvalue ~= 0 then
outvalue = scaled_top / outvalue
end
scaled_value = outvalue
if not valid_number(outvalue) then
if outvalue < 0 then
sortkey = '1000000000000000000'
else
sortkey = '9000000000000000000'
end
elseif outvalue == 0 then
sortkey = '5000000000000000000'
else
local mag = floor(log10(abs(outvalue)) + 1e-14)
local prefix
if outvalue > 0 then
prefix = 7000 + mag
else
prefix = 2999 - mag
outvalue = outvalue + 10^(mag+1)
end
sortkey = format('%d', prefix) .. format('%015.0f', floor(outvalue * 10^(14-mag)))
end
end
local sortspan
if sortkey and not parms.table_align then
sortspan = parms.opt_sortable_debug and
'<span data-sort-value="' .. sortkey .. '♠"><span style="border:1px solid">' .. sortkey .. '♠</span></span>' or
'<span data-sort-value="' .. sortkey .. '♠"></span>'
parms.join_before = sortspan
end
if parms.table_align then
local sort
if sortkey then
sort = ' data-sort-value="' .. sortkey .. '"'
if parms.opt_sortable_debug then
parms.join_before = '<span style="border:1px solid">' .. sortkey .. '</span>'
end
else
sort = ''
end
local style = 'style="text-align:' .. parms.table_align .. ';'
local joins = {}
for i = 1, 2 do
joins[i] = (i == 1 and '' or '\n|') .. style .. user_style(parms, i) .. '"' .. sort .. '|'
end
parms.table_joins = joins
end
return sortspan, scaled_value
end
local cvt_to_hand
local function cvtround(parms, info, in_current, out_current)
-- Return true, t where t is a table with the conversion results; fields:
-- show = rounded, formatted string with the result of converting value in info,
-- using the rounding specified in parms.
-- singular = true if result (after rounding and ignoring any negative sign)
-- is "1", or like "1.00", or is a fraction with value < 1;
-- (and more fields shown below, and a calculated 'absvalue' field).
-- or return false, t where t is an error message table.
-- Input info.clean uses en digits (it has been translated, if necessary).
-- Output show uses en or non-en digits as appropriate, or can be spelled.
if out_current.builtin == 'hand' then
return cvt_to_hand(parms, info, in_current, out_current)
end
local invalue = in_current.builtin == 'hand' and info.altvalue or info.value
local outvalue, extra = convert(parms, invalue, info, in_current, out_current)
if parms.need_table_or_sort then
parms.need_table_or_sort = nil -- process using first input value only
make_table_or_sort(parms, invalue, info, in_current)
end
if extra then
if not outvalue then return false, extra end
invalue = extra.invalue or invalue
outvalue = extra.outvalue
end
if not valid_number(outvalue) then
return false, { 'cvt_invalid_num' }
end
local isnegative
if outvalue < 0 then
isnegative = true
outvalue = -outvalue
end
local precision, show, exponent
local denominator = out_current.frac
if denominator then
show = fraction_table(outvalue, denominator)
else
precision = parms.precision
if not precision then
if parms.sigfig then
show, exponent = make_sigfig(outvalue, parms.sigfig)
elseif parms.opt_round then
local n = parms.opt_round
if n == 0.5 then
local integer, fracpart = math.modf(floor(2 * outvalue + 0.5) / 2)
if fracpart == 0 then
show = format('%.0f', integer)
else
show = format('%.1f', integer + fracpart)
end
else
show = format('%.0f', floor((outvalue / n) + 0.5) * n)
end
elseif in_current.builtin == 'mach' then
local sigfig = info.clean:gsub('^[0.]+', ''):gsub('%.', ''):len() + 1
show, exponent = make_sigfig(outvalue, sigfig)
else
local inclean = info.clean
if extra then
inclean = extra.clean or inclean
show = extra.show
end
if not show then
precision = default_precision(parms, invalue, inclean, info.denominator, outvalue, in_current, out_current, extra)
end
end
end
end
if precision then
if precision >= 0 then
local fudge
if precision <= 8 then
-- Add a fudge to handle common cases of bad rounding due to inability
-- to precisely represent some values. This makes the following work:
-- {{convert|-100.1|C|K}} and {{convert|5555000|um|m|2}}.
-- Old template uses #expr round, which invokes PHP round().
-- LATER: Investigate how PHP round() works.
fudge = 2e-14
else
fudge = 0
end
local fmt = '%.' .. format('%d', precision) .. 'f'
local success
success, show = pcall(format, fmt, outvalue + fudge)
if not success then
return false, { 'cvt_big_prec', tostring(precision) }
end
else
precision = -precision -- #digits to zero (in addition to any digits after dot)
local shift = 10 ^ precision
show = format('%.0f', outvalue/shift)
if show ~= '0' then
exponent = #show + precision
end
end
end
local t = format_number(parms, show, exponent, isnegative)
if type(show) == 'string' then
-- Set singular using match because on some systems 0.99999999999999999 is 1.0.
if exponent then
t.singular = (exponent == 1 and show:match('^10*$'))
else
t.singular = (show == '1' or show:match('^1%.0*$'))
end
else
t.fraction_table = show
t.singular = (outvalue <= 1) -- cannot have 'fraction == 1', but if it were possible it would be singular
end
t.raw_absvalue = outvalue -- absolute value before rounding
return true, setmetatable(t, {
__index = function (self, key)
if key == 'absvalue' then
-- Calculate absolute value after rounding, if needed.
local clean, exponent = rawget(self, 'clean'), rawget(self, 'exponent')
local value = tonumber(clean) -- absolute value (any negative sign has been ignored)
if exponent then
value = value * 10^exponent
end
rawset(self, key, value)
return value
end
end })
end
function cvt_to_hand(parms, info, in_current, out_current)
-- Convert input to hands, inches.
-- Return true, t where t is a table with the conversion results;
-- or return false, t where t is an error message table.
if parms.abbr_org == nil then
out_current.usename = true -- default is to show name not symbol
end
local precision = parms.precision
local frac = out_current.frac
if not frac and precision and precision > 1 then
frac = (precision == 2) and 2 or 4
end
local out_next = out_current.out_next
if out_next then
-- Use magic knowledge to determine whether the next unit is inches without requiring i18n.
-- The following ensures that when the output combination "hand in" is used, the inches
-- value is rounded to match the hands value. Also, displaying say "61½" instead of 61.5
-- is better as 61.5 implies the value is not 61.4.
if out_next.exception == 'subunit_more_precision' then
out_next.frac = frac
end
end
-- Convert to inches; calculate hands from that.
local dummy_unit_table = { scale = out_current.scale / 4, frac = frac }
local success, outinfo = cvtround(parms, info, in_current, dummy_unit_table)
if not success then return false, outinfo end
local tfrac = outinfo.fraction_table
local inches = outinfo.raw_absvalue
if tfrac then
inches = floor(inches) -- integer part only; fraction added later
else
inches = floor(inches + 0.5) -- a hands measurement never shows decimals of an inch
end
local hands, inches = divide(inches, 4)
outinfo.absvalue = hands + inches/4 -- supposed to be the absolute rounded value, but this is close enough
local inchstr = tostring(inches) -- '0', '1', '2' or '3'
if precision and precision <= 0 then -- using negative or 0 for precision rounds to nearest hand
hands = floor(outinfo.raw_absvalue/4 + 0.5)
inchstr = ''
elseif tfrac then
-- Always show an integer before fraction (like "15.0½") because "15½" means 15-and-a-half hands.
inchstr = numdot .. format_fraction(parms, 'out', false, inchstr, tfrac.numstr, tfrac.denstr)
else
inchstr = numdot .. from_en(inchstr)
end
outinfo.show = outinfo.sign .. with_separator(parms, format('%.0f', hands)) .. inchstr
return true, outinfo
end
local function evaluate_condition(value, condition)
-- Return true or false from applying a conditional expression to value,
-- or throw an error if invalid.
-- A very limited set of expressions is supported:
-- v < 9
-- v * 9 < 9
-- where
-- 'v' is replaced with value
-- 9 is any number (as defined by Lua tonumber)
-- only en digits are accepted
-- '<' can also be '<=' or '>' or '>='
-- In addition, the following form is supported:
-- LHS and RHS
-- where
-- LHS, RHS = any of above expressions.
local function compare(value, text)
local arithop, factor, compop, limit = text:match('^%s*v%s*([*]?)(.-)([<>]=?)(.*)$')
if arithop == nil then
error('Invalid default expression', 0)
elseif arithop == '*' then
factor = tonumber(factor)
if factor == nil then
error('Invalid default expression', 0)
end
value = value * factor
end
limit = tonumber(limit)
if limit == nil then
error('Invalid default expression', 0)
end
if compop == '<' then
return value < limit
elseif compop == '<=' then
return value <= limit
elseif compop == '>' then
return value > limit
elseif compop == '>=' then
return value >= limit
end
error('Invalid default expression', 0) -- should not occur
end
local lhs, rhs = condition:match('^(.-%W)and(%W.*)')
if lhs == nil then
return compare(value, condition)
end
return compare(value, lhs) and compare(value, rhs)
end
local function get_default(value, unit_table)
-- Return true, s where s = name of unit's default output unit,
-- or return false, t where t is an error message table.
-- Some units have a default that depends on the input value
-- (the first value if a range of values is used).
-- If '!' is in the default, the first bang-delimited field is an
-- expression that uses 'v' to represent the input value.
-- Example: 'v < 120 ! small ! big ! suffix' (suffix is optional)
-- evaluates 'v < 120' as a boolean with result
-- 'smallsuffix' if (value < 120), or 'bigsuffix' otherwise.
-- Input must use en digits and '.' decimal mark.
local default = data_code.default_exceptions[unit_table.defkey or unit_table.symbol] or unit_table.default
if not default then
local per = unit_table.per
if per then
local function a_default(v, u)
local success, ucode = get_default(v, u)
if not success then
return '?' -- an unlikely error has occurred; will cause lookup of default to fail
end
-- Attempt to use only the first unit if a combination or output multiple.
-- This is not bulletproof but should work for most cases.
-- Where it does not work, the convert will need to specify the wanted output unit.
local t = all_units[ucode]
if t then
local combo = t.combination
if combo then
-- For a multiple like ftin, the "first" unit (ft) is last in the combination.
local i = t.multiple and table_len(combo) or 1
ucode = combo[i]
end
else
-- Try for an automatically generated combination.
local item = ucode:match('^(.-)%+') or ucode:match('^(%S+)%s')
if all_units[item] then
return item
end
end
return ucode
end
local unit1, unit2 = per[1], per[2]
local def1 = (unit1 and a_default(value, unit1) or unit_table.vprefix or '')
local def2 = a_default(1, unit2) -- 1 because per unit of denominator
return true, def1 .. '/' .. def2
end
return false, { 'cvt_no_default', unit_table.symbol }
end
if default:find('!', 1, true) == nil then
return true, default
end
local t = split(default, '!')
if #t == 3 or #t == 4 then
local success, result = pcall(evaluate_condition, value, t[1])
if success then
default = result and t[2] or t[3]
if #t == 4 then
default = default .. t[4]
end
return true, default
end
end
return false, { 'cvt_bad_default', unit_table.symbol }
end
local linked_pages -- to record linked pages so will not link to the same page more than once
local function unlink(unit_table)
-- Forget that the given unit has previously been linked (if it has).
-- That is needed when processing a range of inputs or outputs when an id
-- for the first range value may have been evaluated, but only an id for
-- the last value is displayed, and that id may need to be linked.
linked_pages[unit_table.unitcode or unit_table] = nil
end
local function make_link(link, id, unit_table)
-- Return wikilink "[[link|id]]", possibly abbreviated as in examples:
-- [[Mile|mile]] --> [[mile]]
-- [[Mile|miles]] --> [[mile]]s
-- However, just id is returned if:
-- * no link given (so caller does not need to check if a link was defined); or
-- * link has previously been used during the current convert (to avoid overlinking).
local link_key
if unit_table then
link_key = unit_table.unitcode or unit_table
else
link_key = link
end
if not link or link == '' or linked_pages[link_key] then
return id
end
linked_pages[link_key] = true
-- Following only works for language en, but it should be safe on other wikis,
-- and overhead of doing it generally does not seem worthwhile.
local l = link:sub(1, 1):lower() .. link:sub(2)
if link == id or l == id then
return '[[' .. id .. ']]'
elseif link .. 's' == id or l .. 's' == id then
return '[[' .. id:sub(1, -2) .. ']]s'
else
return '[[' .. link .. '|' .. id .. ']]'
end
end
local function variable_name(clean, unit_table)
-- For slwiki, a unit name depends on the value.
-- Parameter clean is the unsigned rounded value in en digits, as a string.
-- Value Source Example for "m"
-- integer 1: name1 meter (also is the name of the unit)
-- integer 2: var{1} metra
-- integer 3 and 4: var{2} metri
-- integer else: var{3} metrov (0 and 5 or more)
-- real/fraction: var{4} metra
-- var{i} means the i'th field in unit_table.varname if it exists and has
-- an i'th field, otherwise name2.
-- Fields are separated with "!" and are not empty.
-- A field for a unit using an SI prefix has the prefix name inserted,
-- replacing '#' if found, or before the field otherwise.
local vname
if clean == '1' then
vname = unit_table.name1
elseif unit_table.varname then
local i
if clean == '2' then
i = 1
elseif clean == '3' or clean == '4' then
i = 2
elseif clean:find('.', 1, true) then
i = 4
else
i = 3
end
if i > 1 and varname == 'pl' then
i = i - 1
end
vname = split(unit_table.varname, '!')[i]
end
if vname then
local si_name = rawget(unit_table, 'si_name') or ''
local pos = vname:find('#', 1, true)
if pos then
vname = vname:sub(1, pos - 1) .. si_name .. vname:sub(pos + 1)
else
vname = si_name .. vname
end
return vname
end
return unit_table.name2
end
local function linked_id(parms, unit_table, key_id, want_link, clean)
-- Return final unit id (symbol or name), optionally with a wikilink,
-- and update unit_table.sep if required.
-- key_id is one of: 'symbol', 'sym_us', 'name1', 'name1_us', 'name2', 'name2_us'.
local abbr_on = (key_id == 'symbol' or key_id == 'sym_us')
if abbr_on and want_link then
local symlink = rawget(unit_table, 'symlink')
if symlink then
return symlink -- for exceptions that have the linked symbol built-in
end
end
local multiplier = rawget(unit_table, 'multiplier')
local per = unit_table.per
if per then
local paren1, paren2 = '', '' -- possible parentheses around bottom unit
local unit1 = per[1] -- top unit_table, or nil
local unit2 = per[2] -- bottom unit_table
if abbr_on then
if not unit1 then
unit_table.sep = '' -- no separator in "$2/acre"
end
if not want_link then
local symbol = unit_table.symbol_raw
if symbol then
return symbol -- for exceptions that have the symbol built-in
end
end
if (unit2.symbol):find('⋅', 1, true) then
paren1, paren2 = '(', ')'
end
end
local key_id2 -- unit2 is always singular
if key_id == 'name2' then
key_id2 = 'name1'
elseif key_id == 'name2_us' then
key_id2 = 'name1_us'
else
key_id2 = key_id
end
local result
if abbr_on then
result = '/'
elseif omitsep then
result = per_word
elseif unit1 then
result = ' ' .. per_word .. ' '
else
result = per_word .. ' '
end
if want_link and unit_table.link then
if abbr_on or not varname then
result = (unit1 and linked_id(parms, unit1, key_id, false, clean) or '') .. result .. linked_id(parms, unit2, key_id2, false, '1')
else
result = (unit1 and variable_name(clean, unit1) or '') .. result .. variable_name('1', unit2)
end
if omit_separator(result) then
unit_table.sep = ''
end
return make_link(unit_table.link, result, unit_table)
end
if unit1 then
result = linked_id(parms, unit1, key_id, want_link, clean) .. result
if unit1.sep then
unit_table.sep = unit1.sep
end
elseif omitsep then
unit_table.sep = ''
end
return result .. paren1 .. linked_id(parms, unit2, key_id2, want_link, '1') .. paren2
end
if multiplier then
-- A multiplier (like "100" in "100km") forces the unit to be plural.
multiplier = from_en(multiplier)
if not omitsep then
multiplier = multiplier .. (abbr_on and ' ' or ' ')
end
if not abbr_on then
if key_id == 'name1' then
key_id = 'name2'
elseif key_id == 'name1_us' then
key_id = 'name2_us'
end
end
else
multiplier = ''
end
local id = unit_table.fixed_name or ((varname and not abbr_on) and variable_name(clean, unit_table) or unit_table[key_id])
if omit_separator(id) then
unit_table.sep = ''
end
if want_link then
local link = data_code.link_exceptions[unit_table.linkey or unit_table.symbol] or unit_table.link
if link then
local before = ''
local i = unit_table.customary
if i == 1 and parms.opt_sp_us then
i = 2 -- show "U.S." not "US"
end
if i == 3 and abbr_on then
i = 4 -- abbreviate "imperial" to "imp"
end
local customary = text_code.customary_units[i]
if customary then
-- LATER: This works for language en only, but it's esoteric so ignore for now.
local pertext
if id:sub(1, 1) == '/' then
-- Want unit "/USgal" to display as "/U.S. gal", not "U.S. /gal".
pertext = '/'
id = id:sub(2)
elseif id:sub(1, 4) == 'per ' then
-- Similarly want "per U.S. gallon", not "U.S. per gallon" (but in practice this is unlikely to be used).
pertext = 'per '
id = id:sub(5)
else
pertext = ''
end
-- Omit any "US"/"U.S."/"imp"/"imperial" from start of id since that will be inserted.
local removes = (i < 3) and { 'US ', 'US ', 'U.S. ', 'U.S. ' } or { 'imp ', 'imp ', 'imperial ' }
for _, prefix in ipairs(removes) do
local plen = #prefix
if id:sub(1, plen) == prefix then
id = id:sub(plen + 1)
break
end
end
before = pertext .. make_link(customary.link, customary[1]) .. ' '
end
id = before .. make_link(link, id, unit_table)
end
end
return multiplier .. id
end
local function make_id(parms, which, unit_table)
-- Return id, f where
-- id = unit name or symbol, possibly modified
-- f = true if id is a name, or false if id is a symbol
-- using the value for index 'which', and for 'in' or 'out' (unit_table.inout).
-- Result is '' if no symbol/name is to be used.
-- In addition, set unit_table.sep = ' ' or ' ' or ''
-- (the separator that caller will normally insert before the id).
if parms.opt_values then
unit_table.sep = ''
return ''
end
local inout = unit_table.inout
local info = unit_table.valinfo[which]
local abbr_org = parms.abbr_org
local adjectival = parms.opt_adjectival
local lk = parms.lk
local want_link = (lk == 'on' or lk == inout)
local usename = unit_table.usename
local singular = info.singular
local want_name
if usename then
want_name = true
else
if abbr_org == nil then
if parms.wantname then
want_name = true
end
if unit_table.usesymbol then
want_name = false
end
end
if want_name == nil then
local abbr = parms.abbr
if abbr == 'on' or abbr == inout or (abbr == 'mos' and inout == 'out') then
want_name = false
else
want_name = true
end
end
end
local key
if want_name then
if lk == nil and unit_table.builtin == 'hand' then
want_link = true
end
if parms.opt_use_nbsp then
unit_table.sep = ' '
else
unit_table.sep = ' '
end
if parms.opt_singular then
local value
if inout == 'in' then
value = info.value
else
value = info.absvalue
end
if value then -- some unusual units do not always set value field
value = abs(value)
singular = (0 < value and value < 1.0001)
end
end
if unit_table.engscale then
-- engscale: so "|1|e3kg" gives "1 thousand kilograms" (plural)
singular = false
end
key = (adjectival or singular) and 'name1' or 'name2'
if parms.opt_sp_us then
key = key .. '_us'
end
else
if unit_table.builtin == 'hand' then
if parms.opt_hand_hh then
unit_table.symbol = 'hh' -- LATER: might want i18n applied to this
end
end
unit_table.sep = ' '
key = parms.opt_sp_us and 'sym_us' or 'symbol'
end
return linked_id(parms, unit_table, key, want_link, info.clean), want_name
end
local function decorate_value(parms, unit_table, which, number_word)
-- If needed, update unit_table so values will be shown with extra information.
-- For consistency with the old template (but different from fmtpower),
-- the style to display powers of 10 includes "display:none" to allow some
-- browsers to copy, for example, "10³" as "10^3", rather than as "103".
local info
local engscale = unit_table.engscale
local prefix = unit_table.vprefix
if engscale or prefix then
info = unit_table.valinfo[which]
if info.decorated then
return -- do not redecorate if repeating convert
end
info.decorated = true
if engscale then
local inout = unit_table.inout
local abbr = parms.abbr
if (abbr == 'on' or abbr == inout) and not parms.number_word then
info.show = info.show ..
'<span style="margin-left:0.2em">×<span style="margin-left:0.1em">' ..
from_en('10') ..
'</span></span><s style="display:none">^</s><sup>' ..
from_en(tostring(engscale.exponent)) .. '</sup>'
elseif number_word then
local number_id
local lk = parms.lk
if lk == 'on' or lk == inout then
number_id = make_link(engscale.link, engscale[1])
else
number_id = engscale[1]
end
-- WP:NUMERAL recommends " " in values like "12 million".
info.show = info.show .. (parms.opt_adjectival and '-' or ' ') .. number_id
end
end
if prefix then
info.show = prefix .. info.show
end
end
end
local function process_input(parms, in_current)
-- Processing required once per conversion.
-- Return block of text to represent input (value/unit).
if parms.opt_output_only or parms.opt_output_number_only or parms.opt_output_unit_only then
parms.joins = { '', '' }
return ''
end
local first_unit
local composite = in_current.composite -- nil or table of units
if composite then
first_unit = composite[1]
else
first_unit = in_current
end
local id1, want_name = make_id(parms, 1, first_unit)
local sep = first_unit.sep -- separator between value and unit, set by make_id
local preunit = parms.preunit1
if preunit then
sep = '' -- any separator is included in preunit
else
preunit = ''
end
if parms.opt_input_unit_only then
parms.joins = { '', '' }
if composite then
local parts = { id1 }
for i, unit in ipairs(composite) do
if i > 1 then
table.insert(parts, (make_id(parms, 1, unit)))
end
end
id1 = table.concat(parts, ' ')
end
if want_name and parms.opt_adjectival then
return preunit .. hyphenated(id1)
end
return preunit .. id1
end
if parms.opt_also_symbol and not composite and not parms.opt_flip then
local join1 = parms.joins[1]
if join1 == ' (' or join1 == ' [' then
parms.joins = { ' [' .. first_unit[parms.opt_sp_us and 'sym_us' or 'symbol'] .. ']' .. join1 , parms.joins[2] }
end
end
if in_current.builtin == 'mach' and first_unit.sep ~= '' then -- '' means omitsep with non-enwiki name
local prefix = id1 .. ' '
local range = parms.range
local valinfo = first_unit.valinfo
local result = prefix .. valinfo[1].show
if range then
-- For simplicity and because more not needed, handle one range item only.
local prefix2 = make_id(parms, 2, first_unit) .. ' '
result = range_text(range[1], want_name, parms, result, prefix2 .. valinfo[2].show, 'in', {spaced=true})
end
return preunit .. result
end
if composite then
-- Simplify: assume there is no range, and no decoration.
local mid = (not parms.opt_flip) and parms.mid or ''
local sep1 = ' '
local sep2 = ' '
if parms.opt_adjectival and want_name then
sep1 = '-'
sep2 = '-'
end
if omitsep and sep == '' then
-- Testing the id of the most significant unit should be sufficient.
sep1 = ''
sep2 = ''
end
local parts = { first_unit.valinfo[1].show .. sep1 .. id1 }
for i, unit in ipairs(composite) do
if i > 1 then
table.insert(parts, unit.valinfo[1].show .. sep1 .. (make_id(parms, 1, unit)))
end
end
return table.concat(parts, sep2) .. mid
end
local add_unit = (parms.abbr == 'mos') or
parms[parms.opt_flip and 'out_range_x' or 'in_range_x'] or
(not want_name and parms.abbr_range_x)
local range = parms.range
if range and not add_unit then
unlink(first_unit)
end
local id = range and make_id(parms, range.n + 1, first_unit) or id1
local extra, was_hyphenated = hyphenated_maybe(parms, want_name, sep, id, 'in')
if was_hyphenated then
add_unit = false
end
local result
local valinfo = first_unit.valinfo
if range then
for i = 0, range.n do
local number_word
if i == range.n then
add_unit = false
number_word = true
end
decorate_value(parms, first_unit, i+1, number_word)
local show = valinfo[i+1].show
if add_unit then
show = show .. first_unit.sep .. (i == 0 and id1 or make_id(parms, i+1, first_unit))
end
if i == 0 then
result = show
else
result = range_text(range[i], want_name, parms, result, show, 'in')
end
end
else
decorate_value(parms, first_unit, 1, true)
result = valinfo[1].show
end
return result .. preunit .. extra
end
local function process_one_output(parms, out_current)
-- Processing required for each output unit.
-- Return block of text to represent output (value/unit).
local inout = out_current.inout -- normally 'out' but can be 'in' for order=out
local id1, want_name = make_id(parms, 1, out_current)
local sep = out_current.sep -- set by make_id
local preunit = parms.preunit2
if preunit then
sep = '' -- any separator is included in preunit
else
preunit = ''
end
if parms.opt_output_unit_only then
if want_name and parms.opt_adjectival then
return preunit .. hyphenated(id1)
end
return preunit .. id1
end
if out_current.builtin == 'mach' and out_current.sep ~= '' then -- '' means omitsep with non-enwiki name
local prefix = id1 .. ' '
local range = parms.range
local valinfo = out_current.valinfo
local result = prefix .. valinfo[1].show
if range then
-- For simplicity and because more not needed, handle one range item only.
result = range_text(range[1], want_name, parms, result, prefix .. valinfo[2].show, inout, {spaced=true})
end
return preunit .. result
end
local add_unit = (parms[parms.opt_flip and 'in_range_x' or 'out_range_x'] or
(not want_name and parms.abbr_range_x)) and
not parms.opt_output_number_only
local range = parms.range
if range and not add_unit then
unlink(out_current)
end
local id = range and make_id(parms, range.n + 1, out_current) or id1
local extra, was_hyphenated = hyphenated_maybe(parms, want_name, sep, id, inout)
if was_hyphenated then
add_unit = false
end
local result
local valinfo = out_current.valinfo
if range then
for i = 0, range.n do
local number_word
if i == range.n then
add_unit = false
number_word = true
end
decorate_value(parms, out_current, i+1, number_word)
local show = valinfo[i+1].show
if add_unit then
show = show .. out_current.sep .. (i == 0 and id1 or make_id(parms, i+1, out_current))
end
if i == 0 then
result = show
else
result = range_text(range[i], want_name, parms, result, show, inout)
end
end
else
decorate_value(parms, out_current, 1, true)
result = valinfo[1].show
end
if parms.opt_output_number_only then
return result
end
return result .. preunit .. extra
end
local function make_output_single(parms, in_unit_table, out_unit_table)
-- Return true, item where item = wikitext of the conversion result
-- for a single output (which is not a combination or a multiple);
-- or return false, t where t is an error message table.
if parms.opt_order_out and in_unit_table.unitcode == out_unit_table.unitcode then
out_unit_table.valinfo = in_unit_table.valinfo
else
out_unit_table.valinfo = collection()
for _, v in ipairs(in_unit_table.valinfo) do
local success, info = cvtround(parms, v, in_unit_table, out_unit_table)
if not success then return false, info end
out_unit_table.valinfo:add(info)
end
end
return true, process_one_output(parms, out_unit_table)
end
local function make_output_multiple(parms, in_unit_table, out_unit_table)
-- Return true, item where item = wikitext of the conversion result
-- for an output which is a multiple (like 'ftin');
-- or return false, t where t is an error message table.
local inout = out_unit_table.inout -- normally 'out' but can be 'in' for order=out
local multiple = out_unit_table.multiple -- table of scaling factors (will not be nil)
local combos = out_unit_table.combination -- table of unit tables (will not be nil)
local abbr = parms.abbr
local abbr_org = parms.abbr_org
local disp = parms.disp
local want_name = (abbr_org == nil and (disp == 'or' or disp == 'slash')) or
not (abbr == 'on' or abbr == inout or abbr == 'mos')
local want_link = (parms.lk == 'on' or parms.lk == inout)
local mid = parms.opt_flip and parms.mid or ''
local sep1 = ' '
local sep2 = ' '
if parms.opt_adjectival and want_name then
sep1 = '-'
sep2 = '-'
end
local do_spell = parms.opt_spell_out
parms.opt_spell_out = nil -- so the call to cvtround does not spell the value
local function make_result(info, isfirst)
local fmt, outvalue, sign
local results = {}
for i = 1, #combos do
local tfrac, thisvalue, strforce
local out_current = combos[i]
out_current.inout = inout
local scale = multiple[i]
if i == 1 then -- least significant unit ('in' from 'ftin')
local decimals
out_current.frac = out_unit_table.frac
local success, outinfo = cvtround(parms, info, in_unit_table, out_current)
if not success then return false, outinfo end
if isfirst then
out_unit_table.valinfo = { outinfo } -- in case output value of first least significant unit is needed
end
sign = outinfo.sign
tfrac = outinfo.fraction_table
if outinfo.is_scientific then
strforce = outinfo.show
decimals = ''
elseif tfrac then
decimals = ''
else
local show = outinfo.show -- number as a string in local language
local p1, p2 = show:find(numdot, 1, true)
decimals = p1 and show:sub(p2 + 1) or '' -- text after numdot, if any
end
fmt = '%.' .. ulen(decimals) .. 'f' -- to reproduce precision
if decimals == '' then
if tfrac then
outvalue = floor(outinfo.raw_absvalue) -- integer part only; fraction added later
else
outvalue = floor(outinfo.raw_absvalue + 0.5) -- keep all integer digits of least significant unit
end
else
outvalue = outinfo.absvalue
end
end
if scale then
outvalue, thisvalue = divide(outvalue, scale)
else
thisvalue = outvalue
end
local id
if want_name then
if varname then
local clean
if strforce or tfrac then
clean = '.1' -- dummy value to force name for floating point
else
clean = format(fmt, thisvalue)
end
id = variable_name(clean, out_current)
else
local key = 'name2'
if parms.opt_adjectival then
key = 'name1'
elseif tfrac then
if thisvalue == 0 then
key = 'name1'
end
elseif parms.opt_singular then
if 0 < thisvalue and thisvalue < 1.0001 then
key = 'name1'
end
else
if thisvalue == 1 then
key = 'name1'
end
end
id = out_current[key]
end
else
id = out_current['symbol']
end
if i == 1 and omit_separator(id) then
-- Testing the id of the least significant unit should be sufficient.
sep1 = ''
sep2 = ''
end
if want_link then
local link = out_current.link
if link then
id = make_link(link, id, out_current)
end
end
local strval
local spell_inout = (i == #combos or outvalue == 0) and inout or '' -- trick so the last value processed (first displayed) has uppercase, if requested
if strforce and outvalue == 0 then
sign = '' -- any sign is in strforce
strval = strforce -- show small values in scientific notation; will only use least significant unit
elseif tfrac then
local wholestr = (thisvalue > 0) and tostring(thisvalue) or nil
strval = format_fraction(parms, spell_inout, false, wholestr, tfrac.numstr, tfrac.denstr, do_spell)
else
strval = (thisvalue == 0) and from_en('0') or with_separator(parms, format(fmt, thisvalue))
if do_spell then
strval = spell_number(parms, spell_inout, strval) or strval
end
end
table.insert(results, strval .. sep1 .. id)
if outvalue == 0 then
break
end
fmt = '%.0f' -- only least significant unit can have a non-integral value
end
local reversed, count = {}, #results
for i = 1, count do
reversed[i] = results[count + 1 - i]
end
return true, sign .. table.concat(reversed, sep2)
end
local valinfo = in_unit_table.valinfo
local success, result = make_result(valinfo[1], true)
if not success then return false, result end
local range = parms.range
if range then
for i = 1, range.n do
local success, result2 = make_result(valinfo[i+1])
if not success then return false, result2 end
result = range_text(range[i], want_name, parms, result, result2, inout, {spaced=true})
end
end
return true, result .. mid
end
local function process(parms, in_unit_table, out_unit_table)
-- Return true, s, outunit where s = final wikitext result,
-- or return false, t where t is an error message table.
linked_pages = {}
local success, bad_output
local bad_input_mcode = in_unit_table.bad_mcode -- nil if input unit is a valid convert unit
local out_unit = parms.out_unit
if out_unit == nil or out_unit == '' or type(out_unit) == 'function' then
if bad_input_mcode or parms.opt_input_unit_only then
bad_output = ''
else
local getdef = type(out_unit) == 'function' and out_unit or get_default
success, out_unit = getdef(in_unit_table.valinfo[1].value, in_unit_table)
parms.out_unit = out_unit
if not success then
bad_output = out_unit
end
end
end
if not bad_output and not out_unit_table then
success, out_unit_table = lookup(parms, out_unit, 'any_combination')
if success then
local mismatch = check_mismatch(in_unit_table, out_unit_table)
if mismatch then
bad_output = mismatch
end
else
bad_output = out_unit_table
end
end
local lhs, rhs
local flipped = parms.opt_flip and not bad_input_mcode
if bad_output then
rhs = (bad_output == '') and '' or message(parms, bad_output)
elseif parms.opt_input_unit_only then
rhs = ''
else
local combos -- nil (for 'ft' or 'ftin'), or table of unit tables (for 'm ft')
if not out_unit_table.multiple then -- nil/false ('ft' or 'm ft'), or table of factors ('ftin')
combos = out_unit_table.combination
end
local frac = parms.frac -- nil or denominator of fraction for output values
if frac then
-- Apply fraction to the unit (if only one), or to non-SI units (if a combination),
-- except that if a precision is also specified, the fraction only applies to
-- the hand unit; that allows the following result:
-- {{convert|156|cm|in hand|1|frac=2}} → 156 centimetres (61.4 in; 15.1½ hands)
-- However, the following is handled elsewhere as a special case:
-- {{convert|156|cm|hand in|1|frac=2}} → 156 centimetres (15.1½ hands; 61½ in)
if combos then
local precision = parms.precision
for _, unit in ipairs(combos) do
if unit.builtin == 'hand' or (not precision and not unit.prefixes) then
unit.frac = frac
end
end
else
out_unit_table.frac = frac
end
end
local outputs = {}
local imax = combos and #combos or 1 -- 1 (single unit) or number of unit tables
if imax == 1 then
parms.opt_order_out = nil -- only useful with an output combination
end
if not flipped and not parms.opt_order_out then
-- Process left side first so any duplicate links (from lk=on) are suppressed
-- on right. Example: {{convert|28|e9pc|e9ly|abbr=off|lk=on}}
lhs = process_input(parms, in_unit_table)
end
for i = 1, imax do
local success, item
local out_current = combos and combos[i] or out_unit_table
out_current.inout = 'out'
if i == 1 then
if imax > 1 and out_current.builtin == 'hand' then
out_current.out_next = combos[2] -- built-in hand can influence next unit in a combination
end
if parms.opt_order_out then
out_current.inout = 'in'
end
end
if out_current.multiple then
success, item = make_output_multiple(parms, in_unit_table, out_current)
else
success, item = make_output_single(parms, in_unit_table, out_current)
end
if not success then return false, item end
outputs[i] = item
end
if parms.opt_order_out then
lhs = outputs[1]
table.remove(outputs, 1)
end
local sep = parms.table_joins and parms.table_joins[2] or parms.join_between
rhs = table.concat(outputs, sep)
end
if flipped or not lhs then
local input = process_input(parms, in_unit_table)
if flipped then
lhs = rhs
rhs = input
else
lhs = input
end
end
if parms.join_before then
lhs = parms.join_before .. lhs
end
local wikitext
if bad_input_mcode then
if bad_input_mcode == '' then
wikitext = lhs
else
wikitext = lhs .. message(parms, bad_input_mcode)
end
elseif parms.table_joins then
wikitext = parms.table_joins[1] .. lhs .. parms.table_joins[2] .. rhs
else
wikitext = lhs .. parms.joins[1] .. rhs .. parms.joins[2]
end
if parms.warnings and not bad_input_mcode then
wikitext = wikitext .. parms.warnings
end
return true, get_styles(parms) .. wikitext, out_unit_table
end
local function main_convert(frame)
-- Do convert, and if needed, do it again with higher default precision.
local parms = { frame = frame } -- will hold template arguments, after translation
set_config(frame.args)
local success, result = get_parms(parms, frame:getParent().args)
if success then
if type(result) ~= 'table' then
return tostring(result)
end
local in_unit_table = result
local out_unit_table
for _ = 1, 2 do -- use counter so cannot get stuck repeating convert
success, result, out_unit_table = process(parms, in_unit_table, out_unit_table)
if success and parms.do_convert_again then
parms.do_convert_again = false
else
break
end
end
end
-- If input=x gives a problem, the result should be just the user input
-- (if x is a property like P123 it has been replaced with '').
-- An unknown input unit would display the input and an error message
-- with success == true at this point.
-- Also, can have success == false with a message that outputs an empty string.
if parms.input_text then
if success and not parms.have_problem then
return result
end
local cat
if parms.tracking then
-- Add a tracking category using the given text as the category sort key.
-- There is currently only one type of tracking, but in principle multiple
-- items could be tracked, using different sort keys for convenience.
cat = wanted_category('tracking', parms.tracking)
end
return parms.input_text .. (cat or '')
end
return success and result or message(parms, result)
end
local function _unit(unitcode, options)
-- Helper function for Module:Val to look up a unit.
-- Parameter unitcode must be a string to identify the wanted unit.
-- Parameter options must be nil or a table with optional fields:
-- value = number (for sort key; default value is 1)
-- scaled_top = nil for a normal unit, or a number for a unit which is
-- the denominator of a per unit (for sort key)
-- si = { 'symbol', 'link' }
-- (a table with two strings) to make an SI unit
-- that will be used for the look up
-- link = true if result should be [[linked]]
-- sort = 'on' or 'debug' if result should include a sort key in a
-- span element ('debug' makes the key visible)
-- name = true for the name of the unit instead of the symbol
-- us = true for the US spelling of the unit, if any
-- Return nil if unitcode is not a non-empty string.
-- Otherwise return a table with fields:
-- text = requested symbol or name of unit, optionally linked
-- scaled_value = input value adjusted by unit scale; used for sort key
-- sortspan = span element with sort key like that provided by {{ntsh}},
-- calculated from the result of converting value
-- to a base unit with scale 1.
-- unknown = true if the unitcode was not known
unitcode = strip(unitcode)
if unitcode == nil or unitcode == '' then
return nil
end
set_config({})
linked_pages = {}
options = options or {}
local parms = {
abbr = options.name and 'off' or 'on',
lk = options.link and 'on' or nil,
opt_sp_us = options.us and true or nil,
opt_ignore_error = true, -- do not add pages using this function to 'what links here' for Module:Convert/extra
opt_sortable_on = options.sort == 'on' or options.sort == 'debug',
opt_sortable_debug = options.sort == 'debug',
}
if options.si then
-- Make a dummy table of units (just one unit) for lookup to use.
-- This makes lookup recognize any SI prefix in the unitcode.
local symbol = options.si[1] or '?'
parms.unittable = { [symbol] = {
_name1 = symbol,
_name2 = symbol,
_symbol = symbol,
utype = symbol,
scale = symbol == 'g' and 0.001 or 1,
prefixes = 1,
default = symbol,
link = options.si[2],
}}
end
local success, unit_table = lookup(parms, unitcode, 'no_combination')
if not success then
unit_table = setmetatable({
symbol = unitcode, name2 = unitcode, utype = unitcode,
scale = 1, default = '', defkey = '', linkey = '' }, unit_mt)
end
local value = tonumber(options.value) or 1
local clean = tostring(abs(value))
local info = {
value = value,
altvalue = value,
singular = (clean == '1'),
clean = clean,
show = clean,
}
unit_table.inout = 'in'
unit_table.valinfo = { info }
local sortspan, scaled_value
if options.sort then
sortspan, scaled_value = make_table_or_sort(parms, value, info, unit_table, options.scaled_top)
end
return {
text = make_id(parms, 1, unit_table),
sortspan = sortspan,
scaled_value = scaled_value,
unknown = not success and true or nil,
}
end
return { convert = main_convert, _unit = _unit }
cac541bea61c5fbbcb0a2768343935e97587b60a
Module:Infobox/doc
828
83
169
2023-05-19T18:05:05Z
Template>Andrybak
0
add [[Module:Italic title]] to Lua
wikitext
text/x-wiki
{{High-use|3308957|all-pages = yes}}
{{module rating|protected}}
{{Lua|Module:Navbar|Module:Italic title}}
{{Uses TemplateStyles|Module:Infobox/styles.css|Template:Hlist/styles.css|Template:Plainlist/styles.css}}
'''Module:Infobox''' is a [[WP:Module|module]] that implements the {{tl|Infobox}} template. Please see the template page for usage instructions.
== Tracking categories ==
* {{clc|Pages using infobox templates with ignored data cells}}
* {{clc|Articles using infobox templates with no data rows}}
* {{clc|Pages using embedded infobox templates with the title parameter}}
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
[[Category:Modules that add a tracking category]]
[[Category:Wikipedia infoboxes]]
[[Category:Infobox modules]]
[[Category:Modules that check for strip markers]]
}}</includeonly>
936ad219eb263a6f3293d62f667bd7b5db1059c1
Template:Documentation/doc
10
140
283
2023-05-21T19:33:27Z
w>WOSlinker
0
syntaxhighlight lang="wikitext"
wikitext
text/x-wiki
<noinclude>{{pp-semi-indef}}
</noinclude>{{Distinguish|Template:Documentation subpage}}
{{Documentation subpage}}
{{template shortcut|doc}}
{{High-use}}
{{Lua|Module:Documentation}}
{{Never substitute}}
The {{tlx|documentation}} template is used to contain the [[WP:TDOC|documented information and instructions]] of a certain template, usually from a /doc subpage. It can also be configured to load the content from other pages or be directly fed by text.
For detailed instructions on how and when to use this template, see [[Wikipedia:Template documentation]] (shortcut: [[WP:TDOC]]).
This template has two parts: the big "documentation box" with the documentation inside alongside a toolbar (the <code>[view][edit][hist][purge]</code> links), and the smaller "link box" that shows metadata about the documentation alongside the [[Wikipedia:Template sandbox and test cases|sandbox and testcases]] links.
Use of this template allows templates to be [[Wikipedia:Protection policy|protected]], where necessary, while allowing anyone to edit the documentation and categories.
== General syntax ==
Normally, the template is used without parameters and is placed inside {{tag|noinclude}} at the bottom of the template page (see {{section link|#Placement and tags}} for more information):
<syntaxhighlight lang="wikitext">
<!--Last line of your template code--><noinclude>
{{Documentation}}
<!-- Add categories to the /doc subpage -->
</noinclude>
</syntaxhighlight>
=== Transcluding a different page ===
To transclude a different page other than the /doc subpage, simply provide {{para|1}} like this:
<syntaxhighlight lang="wikitext">
<!--Last line of your template code--><noinclude>
{{Documentation|Template:Other page/doc}}
</noinclude>
</syntaxhighlight>
Note that when loading the documentation from a page other than the local /doc subpage, it becomes tricky to handle the categories.
=== Using the {{para|content}} parameter ===
The documentation can also be fed directly as text, by using the {{para|content}} parameter:
<syntaxhighlight lang="wikitext">
<!--Last line of your template code--><noinclude>
{{Documentation
| content =
<!-- template documentation -->
}}</noinclude>
</syntaxhighlight>
When using this parameter, the toolbar will not show. Note that the /doc subpage in the link box will still show up if it exists.
Also note that when {{para|1}} and {{para|content}} is specified, {{para|content}} takes precedence and always shows in the documentation box.
== Advanced syntax ==
=== Customizing the heading ===
The heading in the documentation box changes depending on namespace. See the below list for the default text in each namespace:
* Template namespace: [[File:Test Template Info-Icon - Version (2).svg|32px|link=[[Wikipedia:Template documentation]]]] '''Template documentation'''
* Module namespace: [[File:Test Template Info-Icon - Version (2).svg|32px|link=[[Wikipedia:Template documentation]]]] '''Module documentation'''
* Other namespaces: '''Documentation'''
To customize the heading, simply set the parameter {{para|heading}} to anything you like, for example {{para|heading|Infobox documentation}}.
Note that if the heading parameter is empty but defined (like {{para|heading|}}) the heading alongside the toolbar will not show.
The {{para|heading-style}} parameter can be fed optional [[Cascading Style Sheets|CSS]] values, like {{para|heading-style|font-size:150%;color:red;}}. Not that you should omit quotation marks <code>" "</code> and add the ending semicolon <code>;</code>.
=== Customizing the link box ===
To customize the link box, simply set {{para|link box}} to something else, like {{para|link box|The above documentation is automatically generated from [[Template:Foo]]}}.
To hide the link box, simply set {{para|link box}} to <code>off</code>.
=== Testing ===
You can simulate the output for a given page by using the {{para|page}} parameter. For example, if you use the code {{para|page|Template:Edit protected}}, the template will behave exactly as if it were on the page [[Template:Edit protected]], including showing the documentation from [[Template:Edit protected/doc]], linking to [[Template:Edit protected/sandbox]], etc. This parameter is useful for testing and is used extensively on the [[Module:Documentation/testcases|module testcases page]].
== Placement and tags ==
{{Further information|Wikipedia:Template documentation#Where to place it}}
This code should be added at the bottom of the template code page, with no space before {{Tag|noinclude|o}} (which causes extra whitespace to show on pages where the template is transcluded):
<syntaxhighlight lang="wikitext"><!--Last line of your template code--><noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage -->
</noinclude></syntaxhighlight>
To automatically insert the above text, you can also use the [[Wikipedia:Substitution|substitution]] code shortcut {{tlxs|doc-code}}.
=== Categories and interwikis ===
Depending on where to the documentation is placed, it may be tricky to handle the categories and interwikis. See {{section link|Wikipedia:Template documentation#Categories and interwiki links}} for information about adding these.
== Technical details ==
=== Automatic functions ===
If the documentation page does not exist, the toolbar is replaced with a <code>[create]</code> link. It automatically [[mw:Manual:Creating pages with preloaded text|creates the page with preloaded text]] with the basic documentation syntax. Preload text is also used for the /sandbox and /testcases [create] links.
The preload page for the /doc <code>[create]</code> link is [[Template:Documentation/preload]]. The preload pages for the /sandbox and /testcases links are [[Template:Documentation/preload-sandbox]] and [[Template:Documentation/preload-testcases]]. The preload page for the /sandbox <code>[mirror]</code> link is [[Template:Documentation/mirror]].
This template also automatically adds {{tl|pp-template}} to a protected template page, so no need to manually add this template to protected pages.
When this template is on a /sandbox subpage it automatically adds the {{tl|Template sandbox notice}} template.
=== Link box features ===
Depending on the namespace, the link box may have less features, or may not show up at all. The following table shows this:
{| class="wikitable"
! Namespace
! Behavior
|-
| Template
| Full behavior
|-
| Module
| Full behavior, with the addition of a "create documentation" link when the page does not exist
|-
| User
| Full behavior
|-
| Other namespaces
| Hidden, unless {{para|1}} is specified (which will show "The above documentation is transcluded from {{param|1}}")
|}
Alongside that, if {{para|1}} or {{para|content}} is specified, the "Add categories to the /doc subpage" will not show.
=== Subject namespaces vs. talk namespaces ===
This template is usually placed in the [[WP:NS#Subject namespaces|subject namespace]]. But in some cases this template needs to be on the [[WP:TALKSPACE|Talk namespace]]:
* In the MediaWiki namespace, since {{tag|noinclude|o}} often does not work in system messages, and since the MediaWiki namespace needs to be kept clean for performance reasons.
When placed on talk pages, this template usually is placed near the top of the page and without {{tag|noinclude}} tags.
The /doc, /sandbox and /testcases pages should normally be in the subject namespace, except in the namespaces that do not have the MediaWiki [[meta:Help:Link#Subpage feature|subpage feature]] enabled: Main, File, and MediaWiki. (Categories can have subpages, but documentation is created in the Category talk namespace to prevent creating empty categories. There are also a whole bunch of other technical reasons why the /doc page must be stored under the talk page for those (but only those) namespaces.
This template automatically points its [create] links for the /doc, /sandbox and /testcases to the right namespace.
== Full syntax ==
<syntaxhighlight lang="wikitext">
{{Documentation}}
or
{{Documentation
| [path to documentation page]
}}
{{Documentation
| content =
}}
or
{{Documentation
| [path to documentation page]
| heading-style =
| heading =
| link box =
}}
or
{{Documentation
| [path to documentation page]
| content =
| heading-style =
| heading =
| link box =
| page =
}}
</syntaxhighlight>
=== Color scheme ===
{| class="wikitable" style="font-size:90%"
|+ Wikipedia background colors for {{Template link|documentation}} <small>([[Help:Using colors]])</small>
! !! RGB !! HSV !! Color !! General usage !! Note
|-
| A
| <kbd>#ECFCF4</kbd> || 150°, 6%, 99%
| style="background:#ECFCF4" |
| Sample || Current documentation background
|-
| B
| <kbd>#00FF80</kbd>
| style="font-size:90%;" | {{nowrap|1=Hue=150° <small>(41.7%; 106/255<small>dec</small>)</small> 100%, 100%}}
| style="background:#00FF80" |
| Basic hue || What we'd call ''the color''
|-
| colspan="6" |
|-
| 1
| <kbd>#A3BFB1</kbd> || 150°, 15%, 75%
| style="background:#A3BFB1" |
| Header border only ||
|-
| 2
| <kbd>#CEF2E0</kbd> || 150°, 15%, 95%
| style="background:#CEF2E0" |
| Main border; header background ||
|-
| 3
| <kbd>#E6FFF2</kbd> || 150°, 10%, 100%
| style="background:#E6FFF2" |
| 2nd header, accent colour ||
|-
| 4
| <kbd>#F5FFFA</kbd> || 150°, 4%, 100%
| style="background:#F5FFFA" |
| Main background || So saturation in A is a bit off
|}
{{collapse top|title=Colors for documentation navbox}}
As a suggestion, here are colors for a navbox intended for documentation pages only.
They follow the shading of regular blue navbox colors:
<syntaxhighlight lang="wikitext">
| titlestyle = background:#ccffe5
| basestyle = background:#ddffee
<!-- basestyle= sets groupstyle, abovestyle, belowstyle together -->
</syntaxhighlight>
For subgroups, in child navboxes:
<syntaxhighlight lang="wikitext">
{{Navbox|child
| groupstyle = background:#e6fff2
...
</syntaxhighlight>
Example:{{Template link expanded|Periodic table templates}}
{{collapse bottom}}
==See also==
* {{tl|Documentation subpage}}, a notice placed at the top of a /doc subpage explaining its role and including a link to the page it documents.
* {{tl|Barnstar documentation}}, a variant of {{tl|Documentation}} for use with [[Wikipedia:Barnstars|barnstar]] templates.
* [[Wikipedia:Template documentation]] is a how-to guide to template documentation.
* [[Wikipedia:Template sandbox and test cases]] explains the use of /sandbox and /testcases subpages and includes more information about template testing.
<includeonly><!-- Make sure that only page [[Template:Documentation]] is categorised. No other page (no subpages, not when transcluded).
-->{{#ifeq:{{FULLPAGENAME}}|Template:Documentation|
[[Category:Template documentation| ]]
[[Category:Template namespace templates|Documentation]]
}}</includeonly>
431959208b67db006bc22ce92572aa643072c326
Template:High-use
10
58
119
2023-05-30T09:39:48Z
Template>Lectonar
0
Changed protection settings for "[[Template:High-use]]": [[WP:High-risk templates|High-risk template or module]] ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
wikitext
text/x-wiki
{{#invoke:High-use|main|1={{{1|}}}|2={{{2|}}}|info={{{info|}}}|demo={{{demo|}}}|form={{{form|}}}|expiry={{{expiry|}}}|system={{{system|}}}}}<noinclude>
{{Documentation}}
<!-- Add categories to the /doc subpage; interwiki links go to Wikidata, thank you! -->
</noinclude>
a3322d1bd47ac03df14fa2090855cff4fede9bc7
Module:High-use
828
61
125
2023-05-30T11:20:32Z
Template>Lectonar
0
Changed protection settings for "[[Module:High-use]]": [[WP:High-risk templates|High-risk template or module]] ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
Scribunto
text/plain
local p = {}
-- _fetch looks at the "demo" argument.
local _fetch = require('Module:Transclusion_count').fetch
local yesno = require('Module:Yesno')
function p.num(frame, count)
if count == nil then
if yesno(frame.args['fetch']) == false then
if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
else
count = _fetch(frame)
end
end
-- Build output string
local return_value = ""
if count == nil then
if frame.args[1] == "risk" then
return_value = "a very large number of"
else
return_value = "many"
end
else
-- Use 2 significant figures for smaller numbers and 3 for larger ones
local sigfig = 2
if count >= 100000 then
sigfig = 3
end
-- Prepare to round to appropriate number of sigfigs
local f = math.floor(math.log10(count)) - sigfig + 1
-- Round and insert "approximately" or "+" when appropriate
if (frame.args[2] == "yes") or (mw.ustring.sub(frame.args[1],-1) == "+") then
-- Round down
return_value = string.format("%s+", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) ) * (10^(f))) )
else
-- Round to nearest
return_value = string.format("approximately %s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) )
end
-- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yes
if count and count > 250000 and not yesno (frame:getParent().args['no-percent']) then
local percent = math.floor( ( (count/frame:callParserFunction('NUMBEROFPAGES', 'R') ) * 100) + 0.5)
if percent >= 1 then
return_value = string.format("%s pages, or roughly %s%% of all", return_value, percent)
end
end
end
return return_value
end
-- Actions if there is a large (greater than or equal to 100,000) transclusion count
function p.risk(frame)
local return_value = ""
if frame.args[1] == "risk" then
return_value = "risk"
else
local count = _fetch(frame)
if count and count >= 100000 then return_value = "risk" end
end
return return_value
end
function p.text(frame, count)
-- Only show the information about how this template gets updated if someone
-- is actually editing the page and maybe trying to update the count.
local bot_text = (frame:preprocess("{{REVISIONID}}") == "") and "\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]])." or ''
if count == nil then
if yesno(frame.args['fetch']) == false then
if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
else
count = _fetch(frame)
end
end
local title = mw.title.getCurrentTitle()
if title.subpageText == "doc" or title.subpageText == "sandbox" then
title = title.basePageTitle
end
local systemMessages = frame.args['system']
if frame.args['system'] == '' then
systemMessages = nil
end
-- This retrieves the project URL automatically to simplify localiation.
local templateCount = ('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format(
mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'),
mw.uri.encode(title.fullText), p.num(frame, count))
local used_on_text = "'''This " .. (mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template") .. ' is used ';
if systemMessages then
used_on_text = used_on_text .. systemMessages ..
((count and count > 2000) and ("''', and " .. templateCount) or ("'''"))
else
used_on_text = used_on_text .. templateCount .. "'''"
end
local sandbox_text = ("%s's [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages, or in your own [[%s]]. "):format(
(mw.title.getCurrentTitle().namespace == 828 and "module" or "template"),
title.fullText, title.fullText,
mw.title.getCurrentTitle().namespace == 828 and "Module:Sandbox|module sandbox" or "Wikipedia:User pages#SUB|user subpage"
)
local infoArg = frame.args["info"] ~= "" and frame.args["info"]
if (systemMessages or frame.args[1] == "risk" or (count and count >= 100000) ) then
local info = systemMessages and '.<br/>Changes to it can cause immediate changes to the Wikipedia user interface.' or '.'
if infoArg then
info = info .. "<br />" .. infoArg
end
sandbox_text = info .. '<br /> To avoid major disruption' ..
(count and count >= 100000 and ' and server load' or '') ..
', any changes should be tested in the ' .. sandbox_text ..
'The tested changes can be added to this page in a single edit. '
else
sandbox_text = (infoArg and ('.<br />' .. infoArg .. ' C') or ' and c') ..
'hanges may be widely noticed. Test changes in the ' .. sandbox_text
end
local discussion_text = systemMessages and 'Please discuss changes ' or 'Consider discussing changes '
if frame.args["2"] and frame.args["2"] ~= "" and frame.args["2"] ~= "yes" then
discussion_text = string.format("%sat [[%s]]", discussion_text, frame.args["2"])
else
discussion_text = string.format("%son the [[%s|talk page]]", discussion_text, title.talkPageTitle.fullText )
end
return used_on_text .. sandbox_text .. discussion_text .. " before implementing them." .. bot_text
end
function p.main(frame)
local count = nil
if yesno(frame.args['fetch']) == false then
if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
else
count = _fetch(frame)
end
local image = "[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]"
local type_param = "style"
local epilogue = ''
if frame.args['system'] and frame.args['system'] ~= '' then
image = "[[File:Ambox important.svg|40px|alt=Warning|link=]]"
type_param = "content"
local nocat = frame:getParent().args['nocat'] or frame.args['nocat']
local categorise = (nocat == '' or not yesno(nocat))
if categorise then
epilogue = frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}')
end
elseif (frame.args[1] == "risk" or (count and count >= 100000)) then
image = "[[File:Ambox warning orange.svg|40px|alt=Warning|link=]]"
type_param = "content"
end
if frame.args["form"] == "editnotice" then
return frame:expandTemplate{
title = 'editnotice',
args = {
["image"] = image,
["text"] = p.text(frame, count),
["expiry"] = (frame.args["expiry"] or "")
}
} .. epilogue
else
return require('Module:Message box').main('ombox', {
type = type_param,
image = image,
text = p.text(frame, count),
expiry = (frame.args["expiry"] or "")
}) .. epilogue
end
end
return p
134551888e066954a89c109d2faa8af71a4454a4
Module:Transclusion count
828
62
127
2023-05-30T20:51:38Z
Template>Isabelle Belato
0
Changed protection settings for "[[Module:Transclusion count]]": [[WP:High-risk templates|Highly visible template]]; requested at [[WP:RfPP]] ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
Scribunto
text/plain
local p = {}
function p.fetch(frame)
local template = nil
local return_value = nil
-- Use demo parameter if it exists, otherswise use current template name
local namespace = mw.title.getCurrentTitle().namespace
if frame.args["demo"] and frame.args["demo"] ~= "" then
template = mw.ustring.gsub(frame.args["demo"],"^[Tt]emplate:","")
elseif namespace == 10 then -- Template namespace
template = mw.title.getCurrentTitle().text
elseif namespace == 828 then -- Module namespace
template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text)
end
-- If in template or module namespace, look up count in /data
if template ~= nil then
namespace = mw.title.new(template, "Template").namespace
if namespace == 10 or namespace == 828 then
template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
template = mw.ustring.gsub(template, "/sandbox$", "") -- strip /sandbox from end
local index = mw.ustring.sub(mw.title.new(template).text,1,1)
local status, data = pcall(function ()
return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other")))
end)
if status then
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])
end
end
end
-- If database value doesn't exist, use value passed to template
if return_value == nil and frame.args[1] ~= nil then
local arg1=mw.ustring.match(frame.args[1], '[%d,]+')
if arg1 and arg1 ~= '' then
return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R'))
end
end
return return_value
end
-- Tabulate this data for [[Wikipedia:Database reports/Templates transcluded on the most pages]]
function p.tabulate(frame)
local list = {}
for i = 65, 91 do
local data = mw.loadData('Module:Transclusion count/data/' .. ((i == 91) and 'other' or string.char(i)))
for name, count in pairs(data) do
table.insert(list, {mw.title.new(name, "Template").fullText, count})
end
end
table.sort(list, function(a, b)
return (a[2] == b[2]) and (a[1] < b[1]) or (a[2] > b[2])
end)
local lang = mw.getContentLanguage();
for i = 1, #list do
list[i] = ('|-\n| %d || [[%s]] || %s\n'):format(i, list[i][1]:gsub('_', ' '), lang:formatNum(list[i][2]))
end
return table.concat(list)
end
return p
000ef6bcbf7b66e727870b0c300c4009da300513
Template:Never substitute
10
137
277
2023-07-02T14:23:57Z
w>Primefac
0
convert to wrapper
wikitext
text/x-wiki
{{Always substitute|yesnomaybe=never}}<noinclude>
{{Documentation}}
</noinclude>
fda3e0330f5da78bbcd49a4f97ec81a6a3c78cd5
Template:Always substitute
10
131
265
2023-07-02T18:35:53Z
w>Primefac
0
missing word
wikitext
text/x-wiki
{{{{{|safesubst:}}}#invoke:Unsubst|main|$B=
{{Ombox
| name = Subst only
| type = notice
| text = '''This template {{#switch:{{{yesnomaybe|}}}|may=may be [[Help:Substitution|substituted]]'''|never=should ''not'' be [[Help:Substitution|substituted]]'''||#default=should always be [[Help:Substitution|substituted]]''' (i.e., use <!--
-->{{{actualtemplate|{{template other|{{Tlsp|{{#switch:{{SUBPAGENAME}}|doc|sandbox={{BASEPAGENAME}}|{{PAGENAME}}}}}}|{{Tlsu|{{FULLPAGENAME}}}}}}}}})}}. <!--
-->{{#if:{{yesno|{{{auto|no}}}}} |Any accidental transclusions will be automatically substituted by a bot.{{{1|}}}{{#switch:{{SUBPAGENAME}}|doc|sandbox=|[[Category:Wikipedia templates to be automatically substituted]]}}}} <!--
-->{{#if:{{{alt|}}} |For transcluding, use {{Tl|{{{alt|}}}}} instead.}}
}}{{#switch:{{SUBPAGENAME}}|doc|sandbox=|[[Category:Wikipedia substituted templates]]}}}}<noinclude>{{Documentation}}</noinclude>
8e567c153f4f9a6a329e76bf6a71e8a216e87919
Module:Parameter names example
828
64
131
2023-07-10T09:41:44Z
Template>Gonnym
0
if these are wanted, they should be handled differently (by passing a parameter to this module) as these cause pages to appear as unknown parameters for templates that don't use them
Scribunto
text/plain
-- This module implements {{parameter names example}}.
local p = {}
local function makeParam(s)
local lb = '{'
local rb = '}'
return lb:rep(3) .. s .. rb:rep(3)
end
local function italicize(s)
return "''" .. s .. "''"
end
local function plain(s)
return s
end
function p._main(args, frame)
-- Find how we want to format the arguments to the template.
local formatFunc
if args._display == 'italics' or args._display == 'italic' then
formatFunc = italicize
elseif args._display == 'plain' then
formatFunc = plain
else
formatFunc = makeParam
end
-- Build the table of template arguments.
local targs = {}
for k, v in pairs(args) do
if type(k) == 'number' then
targs[v] = formatFunc(v)
elseif not k:find('^_') then
targs[k] = v
end
end
--targs['nocat'] = 'yes';
--targs['categories'] = 'no';
--targs['demo'] = 'yes';
-- Find the template name.
local template
if args._template then
template = args._template
else
local currentTitle = mw.title.getCurrentTitle()
if currentTitle.prefixedText:find('/sandbox$') then
template = currentTitle.prefixedText
else
template = currentTitle.basePageTitle.prefixedText
end
end
-- Call the template with the arguments.
frame = frame or mw.getCurrentFrame()
local success, result = pcall(
frame.expandTemplate,
frame,
{title = template, args = targs}
)
if success then
return result
else
return ''
end
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Parameter names example'
})
return p._main(args, frame)
end
return p
fdf94fb7a5dc1fabf118d60488a02f1e65b0df24
Module:Documentation
828
51
105
2023-07-31T17:22:10Z
Template>Izno
0
add a comment to make it obvious
Scribunto
text/plain
-- This module implements {{documentation}}.
-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')
local p = {}
-- Often-used functions.
local ugsub = mw.ustring.gsub
local format = mw.ustring.format
----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------
local function message(cfgKey, valArray, expectType)
--[[
-- Gets a message from the cfg table and formats it if appropriate.
-- The function raises an error if the value from the cfg table is not
-- of the type expectType. The default type for expectType is 'string'.
-- If the table valArray is present, strings such as $1, $2 etc. in the
-- message are substituted with values from the table keys [1], [2] etc.
-- For example, if the message "foo-message" had the value 'Foo $2 bar $1.',
-- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz."
--]]
local msg = cfg[cfgKey]
expectType = expectType or 'string'
if type(msg) ~= expectType then
error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
end
if not valArray then
return msg
end
local function getMessageVal(match)
match = tonumber(match)
return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
end
return ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
end
p.message = message
local function makeWikilink(page, display)
if display then
return format('[[%s|%s]]', page, display)
else
return format('[[%s]]', page)
end
end
p.makeWikilink = makeWikilink
local function makeCategoryLink(cat, sort)
local catns = mw.site.namespaces[14].name
return makeWikilink(catns .. ':' .. cat, sort)
end
p.makeCategoryLink = makeCategoryLink
local function makeUrlLink(url, display)
return format('[%s %s]', url, display)
end
p.makeUrlLink = makeUrlLink
local function makeToolbar(...)
local ret = {}
local lim = select('#', ...)
if lim < 1 then
return nil
end
for i = 1, lim do
ret[#ret + 1] = select(i, ...)
end
-- 'documentation-toolbar'
return format(
'<span class="%s">(%s)</span>',
message('toolbar-class'),
table.concat(ret, ' | ')
)
end
p.makeToolbar = makeToolbar
----------------------------------------------------------------------------
-- Argument processing
----------------------------------------------------------------------------
local function makeInvokeFunc(funcName)
return function (frame)
local args = getArgs(frame, {
valueFunc = function (key, value)
if type(value) == 'string' then
value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
if key == 'heading' or value ~= '' then
return value
else
return nil
end
else
return value
end
end
})
return p[funcName](args)
end
end
----------------------------------------------------------------------------
-- Entry points
----------------------------------------------------------------------------
function p.nonexistent(frame)
if mw.title.getCurrentTitle().subpageText == 'testcases' then
return frame:expandTemplate{title = 'module test cases notice'}
else
return p.main(frame)
end
end
p.main = makeInvokeFunc('_main')
function p._main(args)
--[[
-- This function defines logic flow for the module.
-- @args - table of arguments passed by the user
--]]
local env = p.getEnvironment(args)
local root = mw.html.create()
root
:wikitext(p._getModuleWikitext(args, env))
:wikitext(p.protectionTemplate(env))
:wikitext(p.sandboxNotice(args, env))
:tag('div')
-- 'documentation-container'
:addClass(message('container'))
:attr('role', 'complementary')
:attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil)
:attr('aria-label', args.heading == '' and 'Documentation' or nil)
:newline()
:tag('div')
-- 'documentation'
:addClass(message('main-div-classes'))
:newline()
:wikitext(p._startBox(args, env))
:wikitext(p._content(args, env))
:tag('div')
-- 'documentation-clear'
:addClass(message('clear'))
:done()
:newline()
:done()
:wikitext(p._endBox(args, env))
:done()
:wikitext(p.addTrackingCategories(env))
-- 'Module:Documentation/styles.css'
return mw.getCurrentFrame():extensionTag (
'templatestyles', '', {src=cfg['templatestyles']
}) .. tostring(root)
end
----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------
function p.getEnvironment(args)
--[[
-- Returns a table with information about the environment, including title
-- objects and other namespace- or path-related data.
-- @args - table of arguments passed by the user
--
-- Title objects include:
-- env.title - the page we are making documentation for (usually the current title)
-- env.templateTitle - the template (or module, file, etc.)
-- env.docTitle - the /doc subpage.
-- env.sandboxTitle - the /sandbox subpage.
-- env.testcasesTitle - the /testcases subpage.
--
-- Data includes:
-- env.protectionLevels - the protection levels table of the title object.
-- env.subjectSpace - the number of the title's subject namespace.
-- env.docSpace - the number of the namespace the title puts its documentation in.
-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
--
-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
-- returned will be nil.
--]]
local env, envFuncs = {}, {}
-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
-- returned by that function is memoized in the env table so that we don't call any of the functions
-- more than once. (Nils won't be memoized.)
setmetatable(env, {
__index = function (t, key)
local envFunc = envFuncs[key]
if envFunc then
local success, val = pcall(envFunc)
if success then
env[key] = val -- Memoise the value.
return val
end
end
return nil
end
})
function envFuncs.title()
-- The title object for the current page, or a test page passed with args.page.
local title
local titleArg = args.page
if titleArg then
title = mw.title.new(titleArg)
else
title = mw.title.getCurrentTitle()
end
return title
end
function envFuncs.templateTitle()
--[[
-- The template (or module, etc.) title object.
-- Messages:
-- 'sandbox-subpage' --> 'sandbox'
-- 'testcases-subpage' --> 'testcases'
--]]
local subjectSpace = env.subjectSpace
local title = env.title
local subpage = title.subpageText
if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then
return mw.title.makeTitle(subjectSpace, title.baseText)
else
return mw.title.makeTitle(subjectSpace, title.text)
end
end
function envFuncs.docTitle()
--[[
-- Title object of the /doc subpage.
-- Messages:
-- 'doc-subpage' --> 'doc'
--]]
local title = env.title
local docname = args[1] -- User-specified doc page.
local docpage
if docname then
docpage = docname
else
docpage = env.docpageBase .. '/' .. message('doc-subpage')
end
return mw.title.new(docpage)
end
function envFuncs.sandboxTitle()
--[[
-- Title object for the /sandbox subpage.
-- Messages:
-- 'sandbox-subpage' --> 'sandbox'
--]]
return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
end
function envFuncs.testcasesTitle()
--[[
-- Title object for the /testcases subpage.
-- Messages:
-- 'testcases-subpage' --> 'testcases'
--]]
return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
end
function envFuncs.protectionLevels()
-- The protection levels table of the title object.
return env.title.protectionLevels
end
function envFuncs.subjectSpace()
-- The subject namespace number.
return mw.site.namespaces[env.title.namespace].subject.id
end
function envFuncs.docSpace()
-- The documentation namespace number. For most namespaces this is the
-- same as the subject namespace. However, pages in the Article, File,
-- MediaWiki or Category namespaces must have their /doc, /sandbox and
-- /testcases pages in talk space.
local subjectSpace = env.subjectSpace
if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
return subjectSpace + 1
else
return subjectSpace
end
end
function envFuncs.docpageBase()
-- The base page of the /doc, /sandbox, and /testcases subpages.
-- For some namespaces this is the talk page, rather than the template page.
local templateTitle = env.templateTitle
local docSpace = env.docSpace
local docSpaceText = mw.site.namespaces[docSpace].name
-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
return docSpaceText .. ':' .. templateTitle.text
end
function envFuncs.compareUrl()
-- Diff link between the sandbox and the main template using [[Special:ComparePages]].
local templateTitle = env.templateTitle
local sandboxTitle = env.sandboxTitle
if templateTitle.exists and sandboxTitle.exists then
local compareUrl = mw.uri.canonicalUrl(
'Special:ComparePages',
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
)
return tostring(compareUrl)
else
return nil
end
end
return env
end
----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------
p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext')
function p._getModuleWikitext(args, env)
local currentTitle = mw.title.getCurrentTitle()
if currentTitle.contentModel ~= 'Scribunto' then return end
pcall(require, currentTitle.prefixedText) -- if it fails, we don't care
local moduleWikitext = package.loaded["Module:Module wikitext"]
if moduleWikitext then
return moduleWikitext.main()
end
end
function p.sandboxNotice(args, env)
--[=[
-- Generates a sandbox notice for display above sandbox pages.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'sandbox-notice-image' --> '[[File:Sandbox.svg|50px|alt=|link=]]'
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
-- 'sandbox-notice-pagetype-template' --> '[[Wikipedia:Template test cases|template sandbox]] page'
-- 'sandbox-notice-pagetype-module' --> '[[Wikipedia:Template test cases|module sandbox]] page'
-- 'sandbox-notice-pagetype-other' --> 'sandbox page'
-- 'sandbox-notice-compare-link-display' --> 'diff'
-- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'
-- 'sandbox-notice-testcases-link-display' --> 'test cases'
-- 'sandbox-category' --> 'Template sandboxes'
--]=]
local title = env.title
local sandboxTitle = env.sandboxTitle
local templateTitle = env.templateTitle
local subjectSpace = env.subjectSpace
if not (subjectSpace and title and sandboxTitle and templateTitle
and mw.title.equals(title, sandboxTitle)) then
return nil
end
-- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text".
local omargs = {}
omargs.image = message('sandbox-notice-image')
-- Get the text. We start with the opening blurb, which is something like
-- "This is the template sandbox for [[Template:Foo]] (diff)."
local text = ''
local pagetype
if subjectSpace == 10 then
pagetype = message('sandbox-notice-pagetype-template')
elseif subjectSpace == 828 then
pagetype = message('sandbox-notice-pagetype-module')
else
pagetype = message('sandbox-notice-pagetype-other')
end
local templateLink = makeWikilink(templateTitle.prefixedText)
local compareUrl = env.compareUrl
if compareUrl then
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareLink = makeUrlLink(compareUrl, compareDisplay)
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
else
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
end
-- Get the test cases page blurb if the page exists. This is something like
-- "See also the companion subpage for [[Template:Foo/testcases|test cases]]."
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle.contentModel == "Scribunto" then
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
else
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
end
end
-- Add the sandbox to the sandbox category.
omargs.text = text .. makeCategoryLink(message('sandbox-category'))
-- 'documentation-clear'
return '<div class="' .. message('clear') .. '"></div>'
.. require('Module:Message box').main('ombox', omargs)
end
function p.protectionTemplate(env)
-- Generates the padlock icon in the top right.
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
local protectionLevels = env.protectionLevels
if not protectionLevels then
return nil
end
local editProt = protectionLevels.edit and protectionLevels.edit[1]
local moveProt = protectionLevels.move and protectionLevels.move[1]
if editProt then
-- The page is edit-protected.
return require('Module:Protection banner')._main{
message('protection-reason-edit'), small = true
}
elseif moveProt and moveProt ~= 'autoconfirmed' then
-- The page is move-protected but not edit-protected. Exclude move
-- protection with the level "autoconfirmed", as this is equivalent to
-- no move protection at all.
return require('Module:Protection banner')._main{
action = 'move', small = true
}
else
return nil
end
end
----------------------------------------------------------------------------
-- Start box
----------------------------------------------------------------------------
p.startBox = makeInvokeFunc('_startBox')
function p._startBox(args, env)
--[[
-- This function generates the start box.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
-- which generate the box HTML.
--]]
env = env or p.getEnvironment(args)
local links
local content = args.content
if not content or args[1] then
-- No need to include the links if the documentation is on the template page itself.
local linksData = p.makeStartBoxLinksData(args, env)
if linksData then
links = p.renderStartBoxLinks(linksData)
end
end
-- Generate the start box html.
local data = p.makeStartBoxData(args, env, links)
if data then
return p.renderStartBox(data)
else
-- User specified no heading.
return nil
end
end
function p.makeStartBoxLinksData(args, env)
--[[
-- Does initial processing of data to make the [view] [edit] [history] [purge] links.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'view-link-display' --> 'view'
-- 'edit-link-display' --> 'edit'
-- 'history-link-display' --> 'history'
-- 'purge-link-display' --> 'purge'
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'
-- 'docpage-preload' --> 'Template:Documentation/preload'
-- 'create-link-display' --> 'create'
--]]
local subjectSpace = env.subjectSpace
local title = env.title
local docTitle = env.docTitle
if not title or not docTitle then
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
-- Create link if /doc doesn't exist.
local preload = args.preload
if not preload then
if subjectSpace == 828 then -- Module namespace
preload = message('module-preload')
else
preload = message('docpage-preload')
end
end
return {
title = title,
docTitle = docTitle,
-- View, display, edit, and purge links if /doc exists.
viewLinkDisplay = message('view-link-display'),
editLinkDisplay = message('edit-link-display'),
historyLinkDisplay = message('history-link-display'),
purgeLinkDisplay = message('purge-link-display'),
preload = preload,
createLinkDisplay = message('create-link-display')
}
end
function p.renderStartBoxLinks(data)
--[[
-- Generates the [view][edit][history][purge] or [create][purge] links from the data table.
-- @data - a table of data generated by p.makeStartBoxLinksData
--]]
local docTitle = data.docTitle
-- yes, we do intend to purge the template page on which the documentation appears
local purgeLink = makeWikilink("Special:Purge/" .. data.title.prefixedText, data.purgeLinkDisplay)
if docTitle.exists then
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, data.editLinkDisplay)
local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, data.historyLinkDisplay)
return "[" .. viewLink .. "] [" .. editLink .. "] [" .. historyLink .. "] [" .. purgeLink .. "]"
else
local createLink = makeUrlLink(docTitle:canonicalUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
return "[" .. createLink .. "] [" .. purgeLink .. "]"
end
return ret
end
function p.makeStartBoxData(args, env, links)
--[=[
-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
--
-- Messages:
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
-- 'template-namespace-heading' --> 'Template documentation'
-- 'module-namespace-heading' --> 'Module documentation'
-- 'file-namespace-heading' --> 'Summary'
-- 'other-namespaces-heading' --> 'Documentation'
-- 'testcases-create-link-display' --> 'create'
--]=]
local subjectSpace = env.subjectSpace
if not subjectSpace then
-- Default to an "other namespaces" namespace, so that we get at least some output
-- if an error occurs.
subjectSpace = 2
end
local data = {}
-- Heading
local heading = args.heading -- Blank values are not removed.
if heading == '' then
-- Don't display the start box if the heading arg is defined but blank.
return nil
end
if heading then
data.heading = heading
elseif subjectSpace == 10 then -- Template namespace
data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
elseif subjectSpace == 828 then -- Module namespace
data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
elseif subjectSpace == 6 then -- File namespace
data.heading = message('file-namespace-heading')
else
data.heading = message('other-namespaces-heading')
end
-- Heading CSS
local headingStyle = args['heading-style']
if headingStyle then
data.headingStyleText = headingStyle
else
-- 'documentation-heading'
data.headingClass = message('main-div-heading-class')
end
-- Data for the [view][edit][history][purge] or [create] links.
if links then
-- 'mw-editsection-like plainlinks'
data.linksClass = message('start-box-link-classes')
data.links = links
end
return data
end
function p.renderStartBox(data)
-- Renders the start box html.
-- @data - a table of data generated by p.makeStartBoxData.
local sbox = mw.html.create('div')
sbox
-- 'documentation-startbox'
:addClass(message('start-box-class'))
:newline()
:tag('span')
:addClass(data.headingClass)
:attr('id', 'documentation-heading')
:cssText(data.headingStyleText)
:wikitext(data.heading)
local links = data.links
if links then
sbox:tag('span')
:addClass(data.linksClass)
:attr('id', data.linksId)
:wikitext(links)
end
return tostring(sbox)
end
----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------
p.content = makeInvokeFunc('_content')
function p._content(args, env)
-- Displays the documentation contents
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
env = env or p.getEnvironment(args)
local docTitle = env.docTitle
local content = args.content
if not content and docTitle and docTitle.exists then
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end
-- of docs are interpreted correctly.
return '\n' .. (content or '') .. '\n'
end
p.contentTitle = makeInvokeFunc('_contentTitle')
function p._contentTitle(args, env)
env = env or p.getEnvironment(args)
local docTitle = env.docTitle
if not args.content and docTitle and docTitle.exists then
return docTitle.prefixedText
else
return ''
end
end
----------------------------------------------------------------------------
-- End box
----------------------------------------------------------------------------
p.endBox = makeInvokeFunc('_endBox')
function p._endBox(args, env)
--[=[
-- This function generates the end box (also known as the link box).
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
--]=]
-- Get environment data.
env = env or p.getEnvironment(args)
local subjectSpace = env.subjectSpace
local docTitle = env.docTitle
if not subjectSpace or not docTitle then
return nil
end
-- Check whether we should output the end box at all. Add the end
-- box by default if the documentation exists or if we are in the
-- user, module or template namespaces.
local linkBox = args['link box']
if linkBox == 'off'
or not (
docTitle.exists
or subjectSpace == 2
or subjectSpace == 828
or subjectSpace == 10
)
then
return nil
end
-- Assemble the link box.
local text = ''
if linkBox then
text = text .. linkBox
else
text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]."
if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
-- We are in the user, template or module namespaces.
-- Add sandbox and testcases links.
-- "Editors can experiment in this template's sandbox and testcases pages."
text = text .. (p.makeExperimentBlurb(args, env) or '') .. '<br />'
if not args.content and not args[1] then
-- "Please add categories to the /doc subpage."
-- Don't show this message with inline docs or with an explicitly specified doc page,
-- as then it is unclear where to add the categories.
text = text .. (p.makeCategoriesBlurb(args, env) or '')
end
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template"
end
end
local box = mw.html.create('div')
-- 'documentation-metadata'
box:attr('role', 'note')
:addClass(message('end-box-class'))
-- 'plainlinks'
:addClass(message('end-box-plainlinks'))
:wikitext(text)
:done()
return '\n' .. tostring(box)
end
function p.makeDocPageBlurb(args, env)
--[=[
-- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)".
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'edit-link-display' --> 'edit'
-- 'history-link-display' --> 'history'
-- 'transcluded-from-blurb' -->
-- 'The above [[Wikipedia:Template documentation|documentation]]
-- is [[Help:Transclusion|transcluded]] from $1.'
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'
-- 'create-link-display' --> 'create'
-- 'create-module-doc-blurb' -->
-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
--]=]
local docTitle = env.docTitle
if not docTitle then
return nil
end
local ret
if docTitle.exists then
-- /doc exists; link to it.
local docLink = makeWikilink(docTitle.prefixedText)
local editDisplay = message('edit-link-display')
local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, editDisplay)
local historyDisplay = message('history-link-display')
local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, historyDisplay)
ret = message('transcluded-from-blurb', {docLink})
.. ' '
.. makeToolbar(editLink, historyLink)
.. '<br />'
elseif env.subjectSpace == 828 then
-- /doc does not exist; ask to create it.
local createUrl = docTitle:canonicalUrl{action = 'edit', preload = message('module-preload')}
local createDisplay = message('create-link-display')
local createLink = makeUrlLink(createUrl, createDisplay)
ret = message('create-module-doc-blurb', {createLink})
.. '<br />'
end
return ret
end
function p.makeExperimentBlurb(args, env)
--[[
-- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages."
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'sandbox-link-display' --> 'sandbox'
-- 'sandbox-edit-link-display' --> 'edit'
-- 'compare-link-display' --> 'diff'
-- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox'
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
-- 'sandbox-create-link-display' --> 'create'
-- 'mirror-edit-summary' --> 'Create sandbox version of $1'
-- 'mirror-link-display' --> 'mirror'
-- 'mirror-link-preload' --> 'Template:Documentation/mirror'
-- 'sandbox-link-display' --> 'sandbox'
-- 'testcases-link-display' --> 'testcases'
-- 'testcases-edit-link-display'--> 'edit'
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
-- 'testcases-create-link-display' --> 'create'
-- 'testcases-link-display' --> 'testcases'
-- 'testcases-edit-link-display' --> 'edit'
-- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
-- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases'
-- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.'
-- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.'
--]]
local subjectSpace = env.subjectSpace
local templateTitle = env.templateTitle
local sandboxTitle = env.sandboxTitle
local testcasesTitle = env.testcasesTitle
local templatePage = templateTitle.prefixedText
if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
return nil
end
-- Make links.
local sandboxLinks, testcasesLinks
if sandboxTitle.exists then
local sandboxPage = sandboxTitle.prefixedText
local sandboxDisplay = message('sandbox-link-display')
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
local sandboxEditDisplay = message('sandbox-edit-link-display')
local sandboxEditLink = makeWikilink("Special:EditPage/" .. sandboxPage, sandboxEditDisplay)
local compareUrl = env.compareUrl
local compareLink
if compareUrl then
local compareDisplay = message('compare-link-display')
compareLink = makeUrlLink(compareUrl, compareDisplay)
end
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
else
local sandboxPreload
if subjectSpace == 828 then
sandboxPreload = message('module-sandbox-preload')
else
sandboxPreload = message('template-sandbox-preload')
end
local sandboxCreateUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = sandboxPreload}
local sandboxCreateDisplay = message('sandbox-create-link-display')
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorPreload = message('mirror-link-preload')
local mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
if subjectSpace == 828 then
mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
end
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
end
if testcasesTitle.exists then
local testcasesPage = testcasesTitle.prefixedText
local testcasesDisplay = message('testcases-link-display')
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
local testcasesEditUrl = testcasesTitle:canonicalUrl{action = 'edit'}
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeWikilink("Special:EditPage/" .. testcasesPage, testcasesEditDisplay)
-- for Modules, add testcases run link if exists
if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
local testcasesRunLinkDisplay = message('testcases-run-link-display')
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
else
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
end
else
local testcasesPreload
if subjectSpace == 828 then
testcasesPreload = message('module-testcases-preload')
else
testcasesPreload = message('template-testcases-preload')
end
local testcasesCreateUrl = testcasesTitle:canonicalUrl{action = 'edit', preload = testcasesPreload}
local testcasesCreateDisplay = message('testcases-create-link-display')
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
end
local messageName
if subjectSpace == 828 then
messageName = 'experiment-blurb-module'
else
messageName = 'experiment-blurb-template'
end
return message(messageName, {sandboxLinks, testcasesLinks})
end
function p.makeCategoriesBlurb(args, env)
--[[
-- Generates the text "Please add categories to the /doc subpage."
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'doc-link-display' --> '/doc'
-- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.'
--]]
local docTitle = env.docTitle
if not docTitle then
return nil
end
local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
return message('add-categories-blurb', {docPathLink})
end
function p.makeSubpagesBlurb(args, env)
--[[
-- Generates the "Subpages of this template" link.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'template-pagetype' --> 'template'
-- 'module-pagetype' --> 'module'
-- 'default-pagetype' --> 'page'
-- 'subpages-link-display' --> 'Subpages of this $1'
--]]
local subjectSpace = env.subjectSpace
local templateTitle = env.templateTitle
if not subjectSpace or not templateTitle then
return nil
end
local pagetype
if subjectSpace == 10 then
pagetype = message('template-pagetype')
elseif subjectSpace == 828 then
pagetype = message('module-pagetype')
else
pagetype = message('default-pagetype')
end
local subpagesLink = makeWikilink(
'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
message('subpages-link-display', {pagetype})
)
return message('subpages-blurb', {subpagesLink})
end
----------------------------------------------------------------------------
-- Tracking categories
----------------------------------------------------------------------------
function p.addTrackingCategories(env)
--[[
-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'display-strange-usage-category' --> true
-- 'doc-subpage' --> 'doc'
-- 'testcases-subpage' --> 'testcases'
-- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage'
--
-- /testcases pages in the module namespace are not categorised, as they may have
-- {{documentation}} transcluded automatically.
--]]
local title = env.title
local subjectSpace = env.subjectSpace
if not title or not subjectSpace then
return nil
end
local subpage = title.subpageText
local ret = ''
if message('display-strange-usage-category', nil, 'boolean')
and (
subpage == message('doc-subpage')
or subjectSpace ~= 828 and subpage == message('testcases-subpage')
)
then
ret = ret .. makeCategoryLink(message('strange-usage-category'))
end
return ret
end
return p
268dc89480af10873bfbca5439ae8e61b404f770
Template:Template parameter usage
10
60
123
2023-08-10T01:28:48Z
Template>Jonesey95
0
clarify that the linked report applies only to article space
wikitext
text/x-wiki
{{#switch:{{{label|}}}
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|C|c}}lick here] to see a monthly parameter usage report for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|this template}} in articles{{#ifeq:{{yesno-no|{{{based}}}}}|yes| based on {{#if:{{{1|}}}|its|this}} TemplateData}}.
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|P|p}}arameter usage report]{{#ifeq:{{yesno-no|{{{based}}}}}|yes| based on {{#if:{{{1|}}}|its|this}} TemplateData}}
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|P|p}}arameter usage report] for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|[[Template:{{ROOTPAGENAME}}]]}}{{#ifeq:{{yesno-no|{{{based}}}}}|yes| based on {{#if:{{{1|}}}|its|this}} TemplateData}}.
|#default=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{{label|}}}]{{#ifeq:{{yesno-no|{{{based}}}}}|yes| based on {{#if:{{{1|}}}|its|this}} TemplateData}}
}}<noinclude>
{{documentation}}
</noinclude>
10a89e6a4bc63a1427518ea21bf94b8f623a7391
Module:Message box
828
11
25
2023-09-02T22:54:30Z
Template>Anomie
0
[[:File:Cscr-featured.svg]] needs a link to the description page for license and attribution. Add the ability for the configuration to specify a flag to accomplish this.
Scribunto
text/plain
require('strict')
local getArgs
local yesno = require('Module:Yesno')
local lang = mw.language.getContentLanguage()
local CONFIG_MODULE = 'Module:Message box/configuration'
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function getTitleObject(...)
-- Get the title object, passing the function through pcall
-- in case we are over the expensive function count limit.
local success, title = pcall(mw.title.new, ...)
if success then
return title
end
end
local function union(t1, t2)
-- Returns the union of two arrays.
local vals = {}
for i, v in ipairs(t1) do
vals[v] = true
end
for i, v in ipairs(t2) do
vals[v] = true
end
local ret = {}
for k in pairs(vals) do
table.insert(ret, k)
end
table.sort(ret)
return ret
end
local function getArgNums(args, prefix)
local nums = {}
for k, v in pairs(args) do
local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')
if num then
table.insert(nums, tonumber(num))
end
end
table.sort(nums)
return nums
end
--------------------------------------------------------------------------------
-- Box class definition
--------------------------------------------------------------------------------
local MessageBox = {}
MessageBox.__index = MessageBox
function MessageBox.new(boxType, args, cfg)
args = args or {}
local obj = {}
-- Set the title object and the namespace.
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()
-- Set the config for our box type.
obj.cfg = cfg[boxType]
if not obj.cfg then
local ns = obj.title.namespace
-- boxType is "mbox" or invalid input
if args.demospace and args.demospace ~= '' then
-- implement demospace parameter of mbox
local demospace = string.lower(args.demospace)
if DEMOSPACES[demospace] then
-- use template from DEMOSPACES
obj.cfg = cfg[DEMOSPACES[demospace]]
elseif string.find( demospace, 'talk' ) then
-- demo as a talk page
obj.cfg = cfg.tmbox
else
-- default to ombox
obj.cfg = cfg.ombox
end
elseif ns == 0 then
obj.cfg = cfg.ambox -- main namespace
elseif ns == 6 then
obj.cfg = cfg.imbox -- file namespace
elseif ns == 14 then
obj.cfg = cfg.cmbox -- category namespace
else
local nsTable = mw.site.namespaces[ns]
if nsTable and nsTable.isTalk then
obj.cfg = cfg.tmbox -- any talk namespace
else
obj.cfg = cfg.ombox -- other namespaces or invalid input
end
end
end
-- Set the arguments, and remove all blank arguments except for the ones
-- listed in cfg.allowBlankParams.
do
local newArgs = {}
for k, v in pairs(args) do
if v ~= '' then
newArgs[k] = v
end
end
for i, param in ipairs(obj.cfg.allowBlankParams or {}) do
newArgs[param] = args[param]
end
obj.args = newArgs
end
-- Define internal data structure.
obj.categories = {}
obj.classes = {}
-- For lazy loading of [[Module:Category handler]].
obj.hasCategories = false
return setmetatable(obj, MessageBox)
end
function MessageBox:addCat(ns, cat, sort)
if not cat then
return nil
end
if sort then
cat = string.format('[[Category:%s|%s]]', cat, sort)
else
cat = string.format('[[Category:%s]]', cat)
end
self.hasCategories = true
self.categories[ns] = self.categories[ns] or {}
table.insert(self.categories[ns], cat)
end
function MessageBox:addClass(class)
if not class then
return nil
end
table.insert(self.classes, class)
end
function MessageBox:setParameters()
local args = self.args
local cfg = self.cfg
-- Get type data.
self.type = args.type
local typeData = cfg.types[self.type]
self.invalidTypeError = cfg.showInvalidTypeError
and self.type
and not typeData
typeData = typeData or cfg.types[cfg.default]
self.typeClass = typeData.class
self.typeImage = typeData.image
self.typeImageNeedsLink = typeData.imageNeedsLink
-- Find if the box has been wrongly substituted.
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'
-- Find whether we are using a small message box.
self.isSmall = cfg.allowSmall and (
cfg.smallParam and args.small == cfg.smallParam
or not cfg.smallParam and yesno(args.small)
)
-- Add attributes, classes and styles.
self.id = args.id
self.name = args.name
if self.name then
self:addClass('box-' .. string.gsub(self.name,' ','_'))
end
if yesno(args.plainlinks) ~= false then
self:addClass('plainlinks')
end
for _, class in ipairs(cfg.classes or {}) do
self:addClass(class)
end
if self.isSmall then
self:addClass(cfg.smallClass or 'mbox-small')
end
self:addClass(self.typeClass)
self:addClass(args.class)
self.style = args.style
self.attrs = args.attrs
-- Set text style.
self.textstyle = args.textstyle
-- Find if we are on the template page or not. This functionality is only
-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
-- and cfg.templateCategoryRequireName are set.
self.useCollapsibleTextFields = cfg.useCollapsibleTextFields
if self.useCollapsibleTextFields
or cfg.templateCategory
and cfg.templateCategoryRequireName
then
if self.name then
local templateName = mw.ustring.match(
self.name,
'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
) or self.name
templateName = 'Template:' .. templateName
self.templateTitle = getTitleObject(templateName)
end
self.isTemplatePage = self.templateTitle
and mw.title.equals(self.title, self.templateTitle)
end
-- Process data for collapsible text fields. At the moment these are only
-- used in {{ambox}}.
if self.useCollapsibleTextFields then
-- Get the self.issue value.
if self.isSmall and args.smalltext then
self.issue = args.smalltext
else
local sect
if args.sect == '' then
sect = 'This ' .. (cfg.sectionDefault or 'page')
elseif type(args.sect) == 'string' then
sect = 'This ' .. args.sect
end
local issue = args.issue
issue = type(issue) == 'string' and issue ~= '' and issue or nil
local text = args.text
text = type(text) == 'string' and text or nil
local issues = {}
table.insert(issues, sect)
table.insert(issues, issue)
table.insert(issues, text)
self.issue = table.concat(issues, ' ')
end
-- Get the self.talk value.
local talk = args.talk
-- Show talk links on the template page or template subpages if the talk
-- parameter is blank.
if talk == ''
and self.templateTitle
and (
mw.title.equals(self.templateTitle, self.title)
or self.title:isSubpageOf(self.templateTitle)
)
then
talk = '#'
elseif talk == '' then
talk = nil
end
if talk then
-- If the talk value is a talk page, make a link to that page. Else
-- assume that it's a section heading, and make a link to the talk
-- page of the current page with that section heading.
local talkTitle = getTitleObject(talk)
local talkArgIsTalkPage = true
if not talkTitle or not talkTitle.isTalkPage then
talkArgIsTalkPage = false
talkTitle = getTitleObject(
self.title.text,
mw.site.namespaces[self.title.namespace].talk.id
)
end
if talkTitle and talkTitle.exists then
local talkText
if self.isSmall then
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)
talkText = string.format('([[%s|talk]])', talkLink)
else
talkText = 'Relevant discussion may be found on'
if talkArgIsTalkPage then
talkText = string.format(
'%s [[%s|%s]].',
talkText,
talk,
talkTitle.prefixedText
)
else
talkText = string.format(
'%s the [[%s#%s|talk page]].',
talkText,
talkTitle.prefixedText,
talk
)
end
end
self.talk = talkText
end
end
-- Get other values.
self.fix = args.fix ~= '' and args.fix or nil
local date
if args.date and args.date ~= '' then
date = args.date
elseif args.date == '' and self.isTemplatePage then
date = lang:formatDate('F Y')
end
if date then
self.date = string.format(" <span class='date-container'><i>(<span class='date'>%s</span>)</i></span>", date)
end
self.info = args.info
if yesno(args.removalnotice) then
self.removalNotice = cfg.removalNotice
end
end
-- Set the non-collapsible text field. At the moment this is used by all box
-- types other than ambox, and also by ambox when small=yes.
if self.isSmall then
self.text = args.smalltext or args.text
else
self.text = args.text
end
-- Set the below row.
self.below = cfg.below and args.below
-- General image settings.
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
self.imageEmptyCell = cfg.imageEmptyCell
-- Left image settings.
local imageLeft = self.isSmall and args.smallimage or args.image
if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
or not cfg.imageCheckBlank and imageLeft ~= 'none'
then
self.imageLeft = imageLeft
if not imageLeft then
local imageSize = self.isSmall
and (cfg.imageSmallSize or '30x30px')
or '40x40px'
self.imageLeft = string.format('[[File:%s|%s%s|alt=]]', self.typeImage
or 'Information icon4.svg', imageSize, self.typeImageNeedsLink and "" or "|link=" )
end
end
-- Right image settings.
local imageRight = self.isSmall and args.smallimageright or args.imageright
if not (cfg.imageRightNone and imageRight == 'none') then
self.imageRight = imageRight
end
-- set templatestyles
self.base_templatestyles = cfg.templatestyles
self.templatestyles = args.templatestyles
end
function MessageBox:setMainspaceCategories()
local args = self.args
local cfg = self.cfg
if not cfg.allowMainspaceCategories then
return nil
end
local nums = {}
for _, prefix in ipairs{'cat', 'category', 'all'} do
args[prefix .. '1'] = args[prefix]
nums = union(nums, getArgNums(args, prefix))
end
-- The following is roughly equivalent to the old {{Ambox/category}}.
local date = args.date
date = type(date) == 'string' and date
local preposition = 'from'
for _, num in ipairs(nums) do
local mainCat = args['cat' .. tostring(num)]
or args['category' .. tostring(num)]
local allCat = args['all' .. tostring(num)]
mainCat = type(mainCat) == 'string' and mainCat
allCat = type(allCat) == 'string' and allCat
if mainCat and date and date ~= '' then
local catTitle = string.format('%s %s %s', mainCat, preposition, date)
self:addCat(0, catTitle)
catTitle = getTitleObject('Category:' .. catTitle)
if not catTitle or not catTitle.exists then
self:addCat(0, 'Articles with invalid date parameter in template')
end
elseif mainCat and (not date or date == '') then
self:addCat(0, mainCat)
end
if allCat then
self:addCat(0, allCat)
end
end
end
function MessageBox:setTemplateCategories()
local args = self.args
local cfg = self.cfg
-- Add template categories.
if cfg.templateCategory then
if cfg.templateCategoryRequireName then
if self.isTemplatePage then
self:addCat(10, cfg.templateCategory)
end
elseif not self.title.isSubpage then
self:addCat(10, cfg.templateCategory)
end
end
-- Add template error categories.
if cfg.templateErrorCategory then
local templateErrorCategory = cfg.templateErrorCategory
local templateCat, templateSort
if not self.name and not self.title.isSubpage then
templateCat = templateErrorCategory
elseif self.isTemplatePage then
local paramsToCheck = cfg.templateErrorParamsToCheck or {}
local count = 0
for i, param in ipairs(paramsToCheck) do
if not args[param] then
count = count + 1
end
end
if count > 0 then
templateCat = templateErrorCategory
templateSort = tostring(count)
end
if self.categoryNums and #self.categoryNums > 0 then
templateCat = templateErrorCategory
templateSort = 'C'
end
end
self:addCat(10, templateCat, templateSort)
end
end
function MessageBox:setAllNamespaceCategories()
-- Set categories for all namespaces.
if self.invalidTypeError then
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
end
if self.isSubstituted then
self:addCat('all', 'Pages with incorrectly substituted templates')
end
end
function MessageBox:setCategories()
if self.title.namespace == 0 then
self:setMainspaceCategories()
elseif self.title.namespace == 10 then
self:setTemplateCategories()
end
self:setAllNamespaceCategories()
end
function MessageBox:renderCategories()
if not self.hasCategories then
-- No categories added, no need to pass them to Category handler so,
-- if it was invoked, it would return the empty string.
-- So we shortcut and return the empty string.
return ""
end
-- Convert category tables to strings and pass them through
-- [[Module:Category handler]].
return require('Module:Category handler')._main{
main = table.concat(self.categories[0] or {}),
template = table.concat(self.categories[10] or {}),
all = table.concat(self.categories.all or {}),
nocat = self.args.nocat,
page = self.args.page
}
end
function MessageBox:export()
local root = mw.html.create()
-- Add the subst check error.
if self.isSubstituted and self.name then
root:tag('b')
:addClass('error')
:wikitext(string.format(
'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
))
end
local frame = mw.getCurrentFrame()
root:wikitext(frame:extensionTag{
name = 'templatestyles',
args = { src = self.base_templatestyles },
})
-- Add support for a single custom templatestyles sheet. Undocumented as
-- need should be limited and many templates using mbox are substed; we
-- don't want to spread templatestyles sheets around to arbitrary places
if self.templatestyles then
root:wikitext(frame:extensionTag{
name = 'templatestyles',
args = { src = self.templatestyles },
})
end
-- Create the box table.
local boxTable = root:tag('table')
boxTable:attr('id', self.id or nil)
for i, class in ipairs(self.classes or {}) do
boxTable:addClass(class or nil)
end
boxTable
:cssText(self.style or nil)
:attr('role', 'presentation')
if self.attrs then
boxTable:attr(self.attrs)
end
-- Add the left-hand image.
local row = boxTable:tag('tr')
if self.imageLeft then
local imageLeftCell = row:tag('td'):addClass('mbox-image')
if self.imageCellDiv then
-- If we are using a div, redefine imageLeftCell so that the image
-- is inside it. Divs use style="width: 52px;", which limits the
-- image width to 52px. If any images in a div are wider than that,
-- they may overlap with the text or cause other display problems.
imageLeftCell = imageLeftCell:tag('div'):addClass('mbox-image-div')
end
imageLeftCell:wikitext(self.imageLeft or nil)
elseif self.imageEmptyCell then
-- Some message boxes define an empty cell if no image is specified, and
-- some don't. The old template code in templates where empty cells are
-- specified gives the following hint: "No image. Cell with some width
-- or padding necessary for text cell to have 100% width."
row:tag('td')
:addClass('mbox-empty-cell')
end
-- Add the text.
local textCell = row:tag('td'):addClass('mbox-text')
if self.useCollapsibleTextFields then
-- The message box uses advanced text parameters that allow things to be
-- collapsible. At the moment, only ambox uses this.
textCell:cssText(self.textstyle or nil)
local textCellDiv = textCell:tag('div')
textCellDiv
:addClass('mbox-text-span')
:wikitext(self.issue or nil)
if (self.talk or self.fix) then
textCellDiv:tag('span')
:addClass('hide-when-compact')
:wikitext(self.talk and (' ' .. self.talk) or nil)
:wikitext(self.fix and (' ' .. self.fix) or nil)
end
textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)
if self.info and not self.isSmall then
textCellDiv
:tag('span')
:addClass('hide-when-compact')
:wikitext(self.info and (' ' .. self.info) or nil)
end
if self.removalNotice then
textCellDiv:tag('span')
:addClass('hide-when-compact')
:tag('i')
:wikitext(string.format(" (%s)", self.removalNotice))
end
else
-- Default text formatting - anything goes.
textCell
:cssText(self.textstyle or nil)
:wikitext(self.text or nil)
end
-- Add the right-hand image.
if self.imageRight then
local imageRightCell = row:tag('td'):addClass('mbox-imageright')
if self.imageCellDiv then
-- If we are using a div, redefine imageRightCell so that the image
-- is inside it.
imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div')
end
imageRightCell
:wikitext(self.imageRight or nil)
end
-- Add the below row.
if self.below then
boxTable:tag('tr')
:tag('td')
:attr('colspan', self.imageRight and '3' or '2')
:addClass('mbox-text')
:cssText(self.textstyle or nil)
:wikitext(self.below or nil)
end
-- Add error message for invalid type parameters.
if self.invalidTypeError then
root:tag('div')
:addClass('mbox-invalid-type')
:wikitext(string.format(
'This message box is using an invalid "type=%s" parameter and needs fixing.',
self.type or ''
))
end
-- Add categories.
root:wikitext(self:renderCategories() or nil)
return tostring(root)
end
--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------
local p, mt = {}, {}
function p._exportClasses()
-- For testing.
return {
MessageBox = MessageBox
}
end
function p.main(boxType, args, cfgTables)
local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))
box:setParameters()
box:setCategories()
return box:export()
end
function mt.__index(t, k)
return function (frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
end
end
return setmetatable(p, mt)
f2fb84f7b817d2d88747f57c40902a0d8be8158a
Module:Message box/configuration
828
12
27
2023-09-08T14:09:56Z
Template>Pppery
0
Use SVG per edit request
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Message box configuration --
-- --
-- This module contains configuration data for [[Module:Message box]]. --
--------------------------------------------------------------------------------
return {
ambox = {
types = {
speedy = {
class = 'ambox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'ambox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'ambox-content',
image = 'Ambox important.svg'
},
style = {
class = 'ambox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'ambox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'ambox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'ambox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},
allowSmall = true,
smallParam = 'left',
smallClass = 'mbox-small-left',
substCheck = true,
classes = {'metadata', 'ambox'},
imageEmptyCell = true,
imageCheckBlank = true,
imageSmallSize = '20x20px',
imageCellDiv = true,
useCollapsibleTextFields = true,
imageRightNone = true,
sectionDefault = 'article',
allowMainspaceCategories = true,
templateCategory = 'Article message templates',
templateCategoryRequireName = true,
templateErrorCategory = 'Article message templates with missing parameters',
templateErrorParamsToCheck = {'issue', 'fix', 'subst'},
removalNotice = '<small>[[Help:Maintenance template removal|Learn how and when to remove this template message]]</small>',
templatestyles = 'Module:Message box/ambox.css'
},
cmbox = {
types = {
speedy = {
class = 'cmbox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'cmbox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'cmbox-content',
image = 'Ambox important.svg'
},
style = {
class = 'cmbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'cmbox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'cmbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'cmbox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
showInvalidTypeError = true,
classes = {'cmbox'},
imageEmptyCell = true,
templatestyles = 'Module:Message box/cmbox.css'
},
fmbox = {
types = {
warning = {
class = 'fmbox-warning',
image = 'Ambox warning pn.svg'
},
editnotice = {
class = 'fmbox-editnotice',
image = 'Information icon4.svg'
},
system = {
class = 'fmbox-system',
image = 'Information icon4.svg'
}
},
default = 'system',
showInvalidTypeError = true,
classes = {'fmbox'},
imageEmptyCell = false,
imageRightNone = false,
templatestyles = 'Module:Message box/fmbox.css'
},
imbox = {
types = {
speedy = {
class = 'imbox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'imbox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'imbox-content',
image = 'Ambox important.svg'
},
style = {
class = 'imbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'imbox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'imbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
license = {
class = 'imbox-license licensetpl',
image = 'Imbox-license.svg'
},
featured = {
class = 'imbox-featured',
image = 'Cscr-featured.svg',
imageNeedsLink = true
},
notice = {
class = 'imbox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
showInvalidTypeError = true,
classes = {'imbox'},
imageEmptyCell = true,
below = true,
templateCategory = 'File message boxes',
templatestyles = 'Module:Message box/imbox.css'
},
ombox = {
types = {
speedy = {
class = 'ombox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'ombox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'ombox-content',
image = 'Ambox important.svg'
},
style = {
class = 'ombox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'ombox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'ombox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'ombox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
showInvalidTypeError = true,
classes = {'ombox'},
allowSmall = true,
imageEmptyCell = true,
imageRightNone = true,
templatestyles = 'Module:Message box/ombox.css'
},
tmbox = {
types = {
speedy = {
class = 'tmbox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'tmbox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'tmbox-content',
image = 'Ambox important.svg'
},
style = {
class = 'tmbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'tmbox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'tmbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'tmbox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
showInvalidTypeError = true,
classes = {'tmbox'},
allowSmall = true,
imageRightNone = true,
imageEmptyCell = true,
templateCategory = 'Talk message boxes',
templatestyles = 'Module:Message box/tmbox.css'
}
}
27f00af5cf3939613e9156acd5e62a3469d03d81
Template:Infobox/doc
10
71
145
2023-09-09T08:06:21Z
Template>Tjmj
0
/* Examples */ Suppress [[Category:Pages using infobox templates with ignored data cells]]
wikitext
text/x-wiki
{{Documentation subpage}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
{{distinguish|Template:Userbox}}
{{#ifeq:{{SUBPAGENAME}}|sandbox||{{High-use}}}}
{{Lua|Module:Infobox}}
{{Parameter names example
|name={{PAGENAME}} <!--|child |subbox |decat--> |title |above |subheader |subheader1 |subheader2={{{subheader2}}}<br/>......
|image|caption |image1|caption1 |image2|caption2={{{caption2}}}<br/>......
|header1=<div style="border-top:1px dashed #ccc;">{{{header1}}}<br/>{{nobold|( ''or'' )}}</div>
|label2={{{label1}}} |data2={{{data1}}}
|data3=( ''or'' ) |data4=<div style="padding-bottom:0.25em;border-bottom:1px dashed #ccc;">{{{data1}}}</div>
|header5={{{header2}}}<br/><div style="padding:0.75em 0 0.5em;">{{nobold|( ''or'' )}}</div>
|label6={{{label2}}} |data6={{{data2}}}
|data7=( ''or'' ) |data8=<div style="padding-bottom:0.25em;border-bottom:1px dashed #ccc;">{{{data2}}}</div>
|data9=<div style="padding:0.75em 0 0.5em;">( ''etc'' )</div>
|below
}}
This template is intended as a meta template: a template used for constructing other templates. '''Note''': In general, it is not meant for use directly in an article, but can be used on a one-off basis if required. [[Help:Infobox]] contains an introduction about the recommended content and design of infoboxes; [[Wikipedia:Manual of Style/Infoboxes]] contains additional style guidelines. See [[WP:List of infoboxes]] and [[:Category:Infobox templates]] for lists of prepared topic-specific infoboxes.
== Usage ==
{{tlf|Infobox}} is a meta-template: used to organise an actual <nowiki>{{Infobox sometopic}}</nowiki> template (like {{tl|Infobox building}}).
For <code><nowiki>[[Template:Infobox sometopic]]</nowiki></code>, template code then looks like this, simplified:
<syntaxhighlight lang="wikitext">
{{Infobox
| name = {{{name|{{PAGENAME}}}}}
| image = {{{image|}}}
| caption1 = {{{caption|}}}
| label1 = Former names
| data1 = {{{former_names|}}}
| header2 = General information
| label3 = Status
| data3 = {{{status|}}}
... <!-- etc. -->
}}
</syntaxhighlight>
== Optional control parameters ==
; name : If this parameter is present, "view/talk/edit" links will be added to the bottom of the infobox pointing to the named page, prefixed by <code>Template:</code> if no namespace is specified. You may use the value <nowiki>{{subst:PAGENAME}}</nowiki>; however, this is rarely what you want because it will send users clicking these links in an infobox to the template code rather than the data in the infobox they probably want to change.
; child : See the [[#Embedding|Embedding]] section for details. If this is set to "yes", this child infobox should be titled but have no name parameter. This parameter is empty by default, set it to "yes" to activate it.
; subbox : See the [[#Subboxes|Subboxes]] section for details. If this is set to "yes", this subbox should be titled but have no name parameter. This parameter is empty by default, set to "yes" to activate it. It has no effect if the '''child''' parameter is also set to "yes".
; decat : If this is set to "yes", the current page will not be autocategorized in a maintenance category when the generated infobox has some problems or no visible data section. Leave empty by default or set to "yes" to activate it.
; autoheaders: If this is set to any non-blank value, headers which are not followed by data fields are suppressed. See the "[[#Hiding headers when all its data fields are empty|hiding headers when all its data fields are empty]]" section for more details.
== Content parameters ==
=== Title ===
There are two different ways to put a title on an infobox. One contains the title inside the infobox's border in the uppermost cell of the table, the other puts it as a caption on top of the table. You can use them both together, or just one or the other, or neither (though this is not recommended):
; title : Text to put in the caption over the top of the table (or as section header before the whole content of this table, if this is a child infobox). For [[Wikipedia:Manual of Style/Accessibility#Tables|accessibility reasons]], this is the most recommended alternative.
; above : Text to put within the uppermost cell of the table.
; subheader(n) : additional title fields which fit below {{{title}}} and {{{above}}}, but before images.
Examples:
{{Infobox
| name = Infobox/doc
| title = Text in caption over infobox
| subheader = Subheader of the infobox
| header = (the rest of the infobox goes here)
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| name = {{subst:PAGENAME}}
| title = Text in caption over infobox
| subheader = Subheader of the infobox
| header = (the rest of the infobox goes here)
}}
</syntaxhighlight>{{clear}}
{{Infobox
| name = Infobox/doc
| above = Text in uppermost cell of infobox
| subheader = Subheader of the infobox
| subheader2 = Second subheader of the infobox
| header = (the rest of the infobox goes here)
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| name = {{subst:PAGENAME}}
| above = Text in uppermost cell of infobox
| subheader = Subheader of the infobox
| subheader2 = Second subheader of the infobox
| header = (the rest of the infobox goes here)
}}
</syntaxhighlight>{{clear}}
=== Illustration images ===
; image(n) : images to display at the top of the template. Use full image syntax, for example <nowiki>[[File:example.png|200px|alt=Example alt text]]</nowiki>. Image is centered by default. See [[WP:ALT]] for more on alt text.
; caption(n) : Text to put underneath the images.
=== Main data ===
; header(n) : Text to use as a header in row n.
; label(n) : Text to use as a label in row n.
; data(n) : Text to display as data in row n.
Note: for any given value for (n), not all combinations of parameters are permitted. The presence of a {{para|header''(n)''}} will cause the corresponding {{para|data''(n)''}} (and {{para|rowclass''(n)''}} {{para|label''(n)''}}, see below) to be ignored; the absence of a {{para|data''(n)''}} will cause the corresponding {{para|label''(n)''}} to be ignored. Valid combinations for any single row are:
* {{para|class''(n)''}} {{para|header''(n)''}}
* {{para|rowclass''(n)''}} {{para|class''(n)''}} {{para|data''(n)''}}
* {{para|rowclass''(n)''}} {{para|label''(n)''}} {{para|class''(n)''}} {{para|data''(n)''}}
See the rendering of header4, label4, and data4 in the [[#Examples|Examples]] section below.
==== Number ranges ====
To allow flexibility when the layout of an infobox is changed, it may be helpful when developing an infobox to use non-contiguous numbers for header and label/data rows. Parameters for new rows can then be inserted in future without having to renumber existing parameters. For example:
<syntaxhighlight lang="wikitext" style="overflow:auto">
| header3 = Section 1
| label5 = Label A
| data5 = Data A
| label7 = Label C
| data7 = Data C
| header10 = Section 2
| label12 = Label D
| data12 = Data D
</syntaxhighlight>{{clear}}
It is also possible to automatically renumber parameter names by using [[User:Frietjes/infoboxgap.js]] or [[Module:IncrementParams]].
There is no upper limit on numbers but there must be at most 50 between each used number.
==== Making data fields optional ====
A row with a label but no data is not displayed. This allows for the easy creation of optional infobox content rows. To make a row optional use a parameter that defaults to an empty string, like so:
<syntaxhighlight lang="wikitext" style="overflow:auto">
| label5 = Population
| data5 = {{{population|}}}
</syntaxhighlight>{{clear}}
This way if an article doesn't define the population parameter in its infobox the row won't be displayed.
For more complex fields with pre-formatted contents that would still be present even if the parameter wasn't set, you can wrap it all in an "#if" statement to make the whole thing vanish when the parameter is not used. For instance, the "#if" statement in the following example reads "#if:the parameter ''mass'' has been supplied |then display it, followed by 'kg'":
<syntaxhighlight lang="wikitext" style="overflow:auto">
| label6 = Mass
| data6 = {{ #if: {{{mass|}}} | {{{mass}}} kg }}
</syntaxhighlight>{{clear}}
For more on #if, see [[meta:ParserFunctions##if:|here]].
==== Hiding headers when all its data fields are empty ====
You can also make headers automatically hide when their section is empty (has no data-row showing).
Consider this situation:
{{Infobox
| title = Example: header with & without data
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Example: header with & without data
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
</syntaxhighlight>{{clear}}
If you want hide the header when no {{para|data''N''}} values are present, use '''{{para|autoheaders|y}}''':
{{Infobox
| title = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
</syntaxhighlight>{{clear}}
So, header1 will be shown if any of item1, item2, or item3 is defined. If none of the three parameters are defined the header won't be shown and no empty row appears before the next visible content.
Note: if the data has empty css elements, like {{para|data|2=<span style="background:yellow;"></span>}}, this will be treated as non-empty (having data).
If {{para|autoheaders|y}} but there are items that you ''do not'' want to trigger a header, place {{para|headerX|_BLANK_}}. This will serve as an empty header and separate it from the subsequent items.
{{Infobox
| title = Example: blank header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = _BLANK_
| label6 = label6 text | data6 = Some value, but does not trigger header1 or show header5
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = _BLANK_
| label6 = label6 text | data6 = Some value, but does not trigger header1 or show header5
}}
</syntaxhighlight>{{clear}}
=== Footer ===
; below : Text to put in the bottom cell. The bottom cell is intended for footnotes, see-also, and other such information.
== Presentation parameters ==
=== Italic titles ===
Titles of articles with infoboxes may be made italic, in line with [[WP:ITALICTITLE]], by passing the <code>italic title</code> parameter.
* Turn on italic titles by passing {{para|italic title|<nowiki>{{{italic title|}}}</nowiki>}} from the infobox.
* Turn off by default (notably because only Latin script may be safely rendered in this style and italic may be needed to distinguish foreign language from local English language only in that script, but would be difficult to read for other scripts) but allow some instances to be made italic by passing {{para|italic title|<nowiki>{{{italic title|no}}}</nowiki>}}
* Do not make any titles italic by not passing the parameter at all.
=== CSS styling ===
{{div col}}
; bodystyle : Applies to the infobox table as a whole
; titlestyle : Applies only to the title caption. Adding a background color is usually inadvisable since the text is rendered "outside" the infobox.
; abovestyle : Applies only to the "above" cell at the top. The default style has font-size:125%; since this cell is usually used for a title, if you want to use the above cell for regular-sized text include "font-size:100%;" in the abovestyle.
; imagestyle : Applies to the cell the image is in. This includes the text of the image caption, but you should set text properties with captionstyle instead of imagestyle in case the caption is moved out of this cell in the future.
; captionstyle : Applies to the text of the image caption.
; rowstyle(n) : This parameter is inserted into the <code>style</code> attribute for the specified row.
; headerstyle : Applies to all header cells
; subheaderstyle : Applies to all subheader cells
; labelstyle : Applies to all label cells
; datastyle : Applies to all data cells
; belowstyle : Applies only to the below cell
{{div col end}}
=== HTML classes and microformats ===
{{div col}}
; bodyclass : This parameter is inserted into the <code>class</code> attribute for the infobox as a whole.
; titleclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''title''' caption.
<!-- currently not implemented in Lua module
; aboverowclass : This parameter is inserted into the <code>class</code> attribute for the complete table row the '''above''' cell is on.
-->
; aboveclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''above''' cell.
; subheaderrowclass(n) : This parameter is inserted into the <code>class</code> attribute for the complete table row the '''subheader''' is on.
; subheaderclass(n) : This parameter is inserted into the <code>class</code> attribute for the infobox's '''subheader'''.
; imagerowclass(n) : These parameters are inserted into the <code>class</code> attribute for the complete table row their respective '''image''' is on.
; imageclass : This parameter is inserted into the <code>class</code> attribute for the '''image'''.
; rowclass(n) : This parameter is inserted into the <code>class</code> attribute for the specified row including the '''label''' and '''data''' cells.
; class(n) : This parameter is inserted into the <code>class</code> attribute for the '''data''' cell of the specified row. If there's no '''data''' cell it has no effect.
<!-- currently not implemented in Lua module
; belowrowclass : This parameter is inserted into the <code>class</code> attribute for the complete table row the '''below''' cell is on.
-->
; belowclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''below''' cell.
{{div col end}}
This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. Multiple class names may be specified, separated by spaces, some of them being used as selectors for custom styling according to a project policy or to the skin selected in user preferences, others being used for microformats.
To flag an infobox as containing [[hCard]] information, for example, add the following parameter:
<syntaxhighlight lang="wikitext" style="overflow:auto">
| bodyclass = vcard
</syntaxhighlight>{{clear}}
And for each row containing a data cell that's part of the vcard, add a corresponding class parameter:
<syntaxhighlight lang="wikitext" style="overflow:auto">
| class1 = fn
| class2 = org
| class3 = tel
</syntaxhighlight>{{clear}}
...and so forth. "above" and "title" can also be given classes, since these are usually used to display the name of the subject of the infobox.
See [[Wikipedia:WikiProject Microformats]] for more information on adding microformat information to Wikipedia, and [[microformat]] for more information on microformats in general.
== Examples ==
Notice how the row doesn't appear in the displayed infobox when a '''label''' is defined without an accompanying '''data''' cell, and how all of them are displayed when a '''header''' is defined on the same row as a '''data''' cell. Also notice that '''subheaders''' are not bold by default like the '''headers''' used to split the main data section, because this role is meant to be for the '''above''' cell :
{{Suppress categories|
{{Infobox
|name = Infobox/doc
|bodystyle =
|titlestyle =
|abovestyle = background:#cfc;
|subheaderstyle =
|title = Test Infobox
|above = Above text
|subheader = Subheader above image
|subheader2 = Second subheader
|imagestyle =
|captionstyle =
|image = [[File:Example-serious.jpg|200px|alt=Example alt text]]
|caption = Caption displayed below File:Example-serious.jpg
|headerstyle = background:#ccf;
|labelstyle = background:#ddf;
|datastyle =
|header1 = Header defined alone
| label1 =
| data1 =
|header2 =
| label2 = Label defined alone does not display (needs data, or is suppressed)
| data2 =
|header3 =
| label3 =
| data3 = Data defined alone
|header4 = All three defined (header, label, data, all with same number)
| label4 = does not display (same number as a header)
| data4 = does not display (same number as a header)
|header5 =
| label5 = Label and data defined (label)
| data5 = Label and data defined (data)
|belowstyle = background:#ddf;
|below = Below text
}}
}}
<syntaxhighlight lang="wikitext">
{{Infobox
|name = Infobox/doc
|bodystyle =
|titlestyle =
|abovestyle = background:#cfc;
|subheaderstyle =
|title = Test Infobox
|above = Above text
|subheader = Subheader above image
|subheader2 = Second subheader
|imagestyle =
|captionstyle =
|image = [[File:Example-serious.jpg|200px|alt=Example alt text]]
|caption = Caption displayed below File:Example-serious.jpg
|headerstyle = background:#ccf;
|labelstyle = background:#ddf;
|datastyle =
|header1 = Header defined alone
| label1 =
| data1 =
|header2 =
| label2 = Label defined alone does not display (needs data, or is suppressed)
| data2 =
|header3 =
| label3 =
| data3 = Data defined alone
|header4 = All three defined (header, label, data, all with same number)
| label4 = does not display (same number as a header)
| data4 = does not display (same number as a header)
|header5 =
| label5 = Label and data defined (label)
| data5 = Label and data defined (data)
|belowstyle = background:#ddf;
|below = Below text
}}
</syntaxhighlight>
For this example, the {{para|bodystyle}} and {{para|labelstyle}} parameters are used to adjust the infobox width and define a default width for the column of labels:
{{Infobox
|name = Infobox/doc
|bodystyle = width:20em
|titlestyle =
|title = Test Infobox
|headerstyle =
|labelstyle = width:33%
|datastyle =
|header1 =
| label1 = Label 1
| data1 = Data 1
|header2 =
| label2 = Label 2
| data2 = Data 2
|header3 =
| label3 = Label 3
| data3 = Data 3
|header4 = Header 4
| label4 =
| data4 =
|header5 =
| label5 = Label 5
| data5 = Data 5: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|belowstyle =
|below = Below text
}}
<syntaxhighlight lang="wikitext">
{{Infobox
|name = Infobox/doc
|bodystyle = width:20em
|titlestyle =
|title = Test Infobox
|headerstyle =
|labelstyle = width:33%
|datastyle =
|header1 =
| label1 = Label 1
| data1 = Data 1
|header2 =
| label2 = Label 2
| data2 = Data 2
|header3 =
| label3 = Label 3
| data3 = Data 3
|header4 = Header 4
| label4 =
| data4 =
|header5 =
| label5 = Label 5
| data5 = Data 5: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|belowstyle =
|below = Below text
}}
</syntaxhighlight>
== Embedding ==
<!--Linked from [[Template:Subinfobox bodystyle/doc]]-->
One infobox template can be embedded into another using the {{para|child}} parameter. This feature can be used to create a modular infobox, or to create better-defined logical sections. Long ago, it was necessary to use embedding in order to create infoboxes with more than 99 rows; but nowadays there's no limit to the number of rows that can be defined in a single instance of <code><nowiki>{{infobox}}</nowiki></code>.
{{Infobox
| title = Top level title
| data1 = {{Infobox | decat = yes | child = yes
| title = First subsection
| label1= Label 1.1
| data1 = Data 1.1
}}
| data2 = {{Infobox | decat = yes | child = yes
|title = Second subsection
| label1= Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Top level title
| data1 = {{Infobox | decat = yes | child = yes
| title = First subsection
| label1= Label 1.1
| data1 = Data 1.1
}}
| data2 = {{Infobox | decat = yes | child = yes
|title = Second subsection
| label1= Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
</syntaxhighlight>{{clear}}
Note, in the examples above, the child infobox is placed in a <code>data</code> field, not a <code>header</code> field. Notice that the section subheadings are not in bold font if bolding is not explicitly specified. To obtain bold section headings, place the child infobox in a '''header''' field (but not in a '''label''' field because it would not be displayed!), either using
{{Infobox
| title = Top level title
| header1 = {{Infobox | decat = yes | child = yes
| title = First subsection
| label1= Label 1.1
| data1 = Data 1.1
}}
| header2 = {{Infobox | decat = yes | child = yes
| title = Second subsection
| label1= Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Top level title
| header1 = {{Infobox | decat = yes | child = yes
| title = First subsection
| label1= Label 1.1
| data1 = Data 1.1
}}
| header2 = {{Infobox | decat = yes | child = yes
| title = Second subsection
| label1= Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
</syntaxhighlight>{{clear}}
or,
{{Infobox
| title = Top level title
| header1 = First subsection
{{Infobox | decat = yes | child = yes
| label1 = Label 1.1
| data1 = Data 1.1
}}
| header2 = Second subsection
{{Infobox | decat = yes | child = yes
| label1 = Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Top level title
| header1 = First subsection
{{Infobox | decat = yes | child = yes
| label1 = Label 1.1
| data1 = Data 1.1
}}
| header2 = Second subsection
{{Infobox | decat = yes | child = yes
| label1 = Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
</syntaxhighlight>{{clear}}
Note that omitting the {{para|title}} parameter, and not including any text preceding the embedded infobox, may result in spurious blank table rows, creating gaps in the visual presentation. The garbage output can be suppressed using {{para|rowstyleN|display: none}}, replacing N with the data/header number.
[[Wikipedia:WikiProject Infoboxes/embed]] includes some links to Wikipedia articles which include infoboxes embedded within other infoboxes.
== Subboxes ==
An alternative method for embedding is to use {{para|subbox|yes}}, which removes the outer border from the infobox, but preserves the interior structure. One feature of this approach is that the parent and child boxes need not have the same structure, and the label and data fields are not aligned between the parent and child boxes because they are not in the same parent table.
{{Infobox
| headerstyle = background-color:#eee;
| labelstyle = background-color:#eee;
| header1 = Main 1
| header2 = Main 2
| data3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| data4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| label5 = Label 5 | data5 = Data 5
| header6 = Main 6
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| headerstyle = background-color:#eee;
| labelstyle = background-color:#eee;
| header1 = Main 1
| header2 = Main 2
| data3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| data4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| label5 = Label 5 | data5 = Data 5
| header6 = Main 6
}}
</syntaxhighlight>{{clear}}
Similar embedding techniques may be used within content parameters of some other templates generating tables (such as [[:Template:Sidebar|Sidebar]]) :
{{Sidebar
| navbar = off
| headingstyle = background-color:#eee;
| heading1 = Heading 1
| heading2 = Heading 2
| content3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| content4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| heading5 = Heading 5
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Sidebar
| navbar = off
| headingstyle = background-color:#eee;
| heading1 = Heading 1
| heading2 = Heading 2
| content3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| content4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| heading5 = Heading 5
}}
</syntaxhighlight>{{clear}}
Note that the default padding of the parent data cell containing each subbox is still visible, so the subboxes are slightly narrower than the parent box and there's a higher vertical spacing between standard cells of the parent box than between cells of distinct subboxes.
== Controlling line-breaking in embedded bulletless lists ==
Template {{tlx|nbsp}} may be used with {{tlx|wbr}} and {{tlx|nowrap}} to control line-breaking in bulletless lists embedded in infoboxes (e.g. cast list in {{tlx|Infobox film}}), to prevent wrapped long entries from being confused with multiple entries. See [[Template:Wbr/doc#Controlling line-breaking in infoboxes]] for details.
== Full blank syntax ==
(Note: there is no limit to the number of possible rows; only 20 are given below since infoboxes larger than that will be relatively rare. Just extend the numbering as needed. The microformat "class" parameters are also omitted as they are not commonly used.)
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| name = {{subst:PAGENAME}}
| child = {{{child|}}}
| subbox = {{{subbox|}}}
| italic title = {{{italic title|no}}}
| templatestyles =
| child templatestyles =
| grandchild templatestyles =
| bodystyle =
| titlestyle =
| abovestyle =
| subheaderstyle =
| title =
| above =
| subheader =
| imagestyle =
| captionstyle =
| image =
| caption =
| image2 =
| caption2 =
| headerstyle =
| labelstyle =
| datastyle =
| header1 =
| label1 =
| data1 =
| header2 =
| label2 =
| data2 =
| header3 =
| label3 =
| data3 =
| header4 =
| label4 =
| data4 =
| header5 =
| label5 =
| data5 =
| header6 =
| label6 =
| data6 =
| header7 =
| label7 =
| data7 =
| header8 =
| label8 =
| data8 =
| header9 =
| label9 =
| data9 =
| header10 =
| label10 =
| data10 =
| header11 =
| label11 =
| data11 =
| header12 =
| label12 =
| data12 =
| header13 =
| label13 =
| data13 =
| header14 =
| label14 =
| data14 =
| header15 =
| label15 =
| data15 =
| header16 =
| label16 =
| data16 =
| header17 =
| label17 =
| data17 =
| header18 =
| label18 =
| data18 =
| header19 =
| label19 =
| data19 =
| header20 =
| label20 =
| data20 =
| belowstyle =
| below =
}}
</syntaxhighlight>{{clear}}
{{Help:Infobox/user style}}
== Porting to other MediaWikis ==
The infobox template requires the [[:mw:Extension:Scribunto|Scribunto]] and [[:mw:Extension:TemplateStyles|TemplateStyles]] extensions. [[Wikipedia:WikiProject Transwiki|WikiProject Transwiki]] has a version of this template that has been modified to work on other MediaWikis.
== TemplateData ==
{{TemplateData header}}
<templatedata>
{
"description": "This template is intended as a meta template, a template used for constructing other templates. In general, it is not meant for use directly in an article but can be used on a one-off basis if required.",
"format": "{{_\n| ________________ = _\n}}\n",
"params": {
"title": {
"label": "Title",
"description": "Title displayed above the infobox",
"type": "string",
"suggested": true
},
"image": {
"label": "Image",
"description": "Image illustrating the topic. Use full image syntax.",
"type": "content",
"suggested": true,
"example": "[[File:example.png|200px|alt=Example alt text]]"
},
"caption": {
"label": "Caption",
"description": "caption for the image",
"type": "content",
"suggested": true
}
},
"paramOrder": [
"title",
"image",
"caption"
]
}
</templatedata>
==Tracking categories==
* {{Category link with count|Articles with missing Wikidata information}}
* {{Category link with count|Articles using infobox templates with no data rows}}
* {{Category link with count|Pages using embedded infobox templates with the title parameter}}
==See also==
* [[Module:Infobox]], the [[WP:LUA|Lua]] module on which this template is based
* [[Module:Check for unknown parameters]]
* {{tl|Infobox3cols}}
* {{tl|Navbox}} and {{tl|Sidebar}}
* [[Wikipedia:List of infoboxes|List of infoboxes]]
* [[:Module:InfoboxImage]]
<includeonly>{{Sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Infobox templates| ]]
[[Category:Wikipedia metatemplates|Infobox]]
[[Category:Templates generating microformats]]
[[Category:Templates that add a tracking category]]
[[Category:Templates based on the Infobox Lua module]]
}}</includeonly>
b7ba187ea76ee960bbe295ad01c44c646eaedadb
Template:Being deleted
10
114
231
2023-09-12T07:41:27Z
w>Primefac
0
reword entirely - it was a weird grammatical construction before, and a weird one after the previous change, so just move the subclause to its own sentence
wikitext
text/x-wiki
{{#switch:{{{_demospace|{{NAMESPACE}}}}}|Template|Module={{Mbox
| type = delete
| image = none
| text = '''This {{#if:{{{module|}}}|module|template}} is currently being {{#if:{{{merge|}}}|merged with [[{{{merge}}}]]|[[Wikipedia:Deletion policy|deleted]]}}.'''<br />This {{#if:{{{module|}}}|module|template}} is being {{#if:{{{merge|}}}|merged with another {{#if:{{{module|}}}|module|template}}|removed from the pages on which it is currently used}}, after which it will be {{#if:{{{merge|}}}|redirected or deleted|deleted}}. '''Please check [[Wikipedia:Templates for discussion/Holding cell]] for any additional instructions'''. {{#if:{{{merge|}}}||Please do not use it on any additional pages, but do not remove it from pages if it is under [[Wikipedia:Deletion review|deletion review]].}} The decision to {{#if:{{{merge|}}}|merge|delete}} this template was made following [[Wikipedia:Templates for discussion/Log/{{Date|{{{date|{{{1}}}}}}|ymd}}#{{#if:{{{template|{{{2|}}}}}}|{{{template|{{{2}}}}}}|{{#if:{{{module|}}}|{{{module}}}|Template:{{PAGENAME}}}}}}|this discussion initiated on {{Date|{{YMD to ISO|{{{date|{{{1}}}}}}}}|dmy}}]] at [[Wikipedia:Templates for discussion|Templates for discussion]].<small>{{#if:{{{merge|}}}|<br/>'''Note''': Please review this template's instructions at [[Wikipedia:Templates for discussion/Holding cell]] before proceeding with any type of merging.|<span class="sysop-show"><br/>'''[[Wikipedia:Administrators|Administrators]]''': Please review this {{#if:{{{module|}}}|module|template}}'s instructions at [[Wikipedia:Templates for discussion/Holding cell]] before proceeding with any action.</span>}}</small>
}}{{#if:{{{nocat|<noinclude>yes</noinclude>}}}||[[Category:Wikipedia templates currently being merged or deleted]]}}
|{{#switch:{{lc:{{{type}}}}}
<!-- Sidebar version, used if type=sidebar-->
|infobox|box|sidebar= <div class="boilerplate metadata plainlinks" id="tfd" style="background-color: transparent; padding: 0; font-size:xx-small; color:#000000; text-align: center; position: relative; float: right; border-bottom:1px solid #AAAAAA; width: {{if empty|{{{width|}}}|27em}}">‹ The {{#if:{{{module|}}}|[[Help:Module|module]]|[[Help:Template|template]]}} below {{#if:{{{module|{{{template|{{{2|}}}}}}}}}|([[{{{module|{{{template|{{{2}}}}}}}}}|{{PAGENAME:{{{module|{{{template|{{{2}}}}}}}}}}}]])}} is being {{#if:{{{merge|}}}|merged|deleted}}. See [[Wikipedia:Templates for discussion/Log/{{Date|{{{date|{{{1}}}}}}|ymd}}#{{#if:1|{{{module|{{{template|{{{2|}}}}}}}}}}}|templates for discussion]] for the discussion that led to this result. ›</div>
<!-- Default version, used in all other cases -->
|#default = <div class="boilerplate metadata plainlinks" id="tfd" style="background-color: transparent; padding: 0; font-size:xx-small; color:#000000; text-align: center; border-bottom:1px solid #AAAAAA;">‹ The {{#if:{{{module|}}}|[[Help:Module|module]]|[[Help:Template|template]]}} below {{#if:{{{module|{{{template|{{{2|}}}}}}}}}|([[{{{module|{{{template|{{{2}}}}}}}}}|{{PAGENAME:{{{module|{{{template|{{{2}}}}}}}}}}}]])}} is being {{#if:{{{merge|}}}|merged|deleted}}. See [[Wikipedia:Templates for discussion/Log/{{Date|{{{date|{{{1}}}}}}|ymd}}#{{#if:1|{{{module|{{{template|{{{2|}}}}}}}}}}}|templates for discussion]] for the discussion that led to this result. ›</div>
}}
}}<!-- integrate with Twinkle CSD module --><span id="delete-reason" style="display:none">{{urlencode:[[WP:CSD#G6|G6]]: [[Wikipedia:Templates for discussion/Log/{{Date|{{{date|{{{1}}}}}}|ymd}}#{{#if:{{{template|{{{2|}}}}}}|{{{template|{{{2}}}}}}|{{#if:{{{module|}}}|{{{module}}}|Template:{{PAGENAME}}}}}}]]}}</span><span id="delete-criterion" style="display:none">{{uc:{{{criterion}}}}}</span><noinclude>
{{Documentation}}
</noinclude>
50afbcb02152b5f6e6eee9e05c74e21afceefd90
Template:Infobox ship begin/shared doc
10
117
237
2023-09-22T12:05:18Z
w>Hildeoc
0
ce
wikitext
text/x-wiki
{{Documentation subpage|override=shared doc|a group of templates}}{{#ifeq:{{BASEPAGENAME}}|Infobox ship begin|{{lua|Module:WPSHIPS utilities}}
: ''N.B.: {{tl|Infobox ship begin}} contains code that can automatically style a variety of ship and ship-class article titles. It adds a [[WP:DISPLAYTITLE|DISPLAYTITLE]] with italics unless'' <code>{{!}}display title=none</code> ''is specified. For details see: the infobox usage guide § [[Template:Infobox ship begin/Usage guide#Title styling|Title styling]].''}}
This ship infobox supports a very large number of fields, including some specialty fields that will rarely be used. Some fields simply don't make sense in some cases. Some different sets of code have been prepared using only the most common fields. Select the most appropriate set below and copy and paste the entire code to the top of a ship article, then fill in as many fields as possible. Empty fields should generally be kept so that a future editor can fill them in unless they make no sense for the ship in question.
The "Full" code contains every field the template supports. If you want, you can copy one of the simplified sets of code and add a few fields from the "Full" code.
If you have ideas for improvements or would like to add brand new fields to these templates, please post on [[Template talk:Infobox ship begin]] to discuss the changes and how they should be implemented.
=== Usage ===
==== Code for individual ships ====
For infoboxes of individual ships, please copy the appropriate example for the type of ship:
{{collapse top |bg=#d0e5f5 |title=Warships (except submarines). {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- warships except submarines -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship owner=
|Ship namesake=
|Ship ordered=
|Ship builder=
|Ship laid down=
|Ship launched=
|Ship acquired=
|Ship commissioned=
|Ship decommissioned=
|Ship in service=
|Ship out of service=
|Ship stricken=
|Ship reinstated=
|Ship honours=
|Ship honors=
|Ship fate=
|Ship status=
|Ship notes=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship propulsion=
|Ship speed=
|Ship range=
|Ship complement=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship armour=
|Ship armor=
|Ship aircraft=
|Ship aircraft facilities=
|Ship notes=
}}
|}
</syntaxhighlight>
{{collapse bottom}}<!-- end of warships except submarines -->
{{collapse top |bg=#d0e5f5 |title=Submarines. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- submarines -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship namesake=
|Ship ordered=
|Ship builder=
|Ship laid down=
|Ship launched=
|Ship acquired=
|Ship commissioned=
|Ship decommissioned=
|Ship in service=
|Ship out of service=
|Ship stricken=
|Ship reinstated=
|Ship fate=
|Ship status=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship propulsion=
|Ship speed=
|Ship range=
|Ship endurance=
|Ship test depth=
|Ship complement=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of submarines -->
{{collapse top |bg=#d0e5f5 |title=Age of sail. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- age of sail -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship owner=
|Ship ordered=
|Ship builder=
|Ship original cost=
|Ship laid down=
|Ship launched=
|Ship acquired=
|Ship commissioned=
|Ship decommissioned=
|Ship in service=
|Ship out of service=
|Ship renamed=
|Ship stricken=
|Ship reinstated=
|Ship honours=
|Ship honors=
|Ship captured=
|Ship fate=
|Ship status=
|Ship notes=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship tons burthen=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship hold depth=
|Ship propulsion=
|Ship sail plan=
|Ship complement=
|Ship armament=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of Age of Sail -->
{{collapse top |bg=#d0e5f5 |title=Commercial vessels. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- commercial vessels -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship name=
|Ship owner=
|Ship operator=
|Ship registry=
|Ship route=
|Ship ordered=
|Ship builder=
|Ship original cost=
|Ship yard number=
|Ship way number=
|Ship laid down=
|Ship launched=
|Ship completed=
|Ship christened=
|Ship acquired=
|Ship maiden voyage=
|Ship in service=
|Ship out of service=
|Ship identification=
|Ship fate=
|Ship status=
|Ship notes=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship type=
|Ship tonnage=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship height=
|Ship draught=
|Ship draft=
|Ship depth=
|Ship decks=
|Ship deck clearance=
|Ship ramps=
|Ship ice class=
|Ship sail plan=
|Ship power=
|Ship propulsion=
|Ship speed=
|Ship capacity=
|Ship crew=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of commercial vessels -->
<br />
If none of the above fit, you may use this full setup:
{{collapse top |bg=#d0e5f5 |title=Full code for individual ships. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- full code -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship namesake=
|Ship owner=
|Ship operator=
|Ship registry=
|Ship route=
|Ship ordered=
|Ship awarded=
|Ship builder=
|Ship original cost=
|Ship yard number=
|Ship way number=
|Ship laid down=
|Ship launched=
|Ship sponsor=
|Ship christened=
|Ship completed=
|Ship acquired=
|Ship commissioned=
|Ship recommissioned=
|Ship decommissioned=
|Ship maiden voyage=
|Ship in service=
|Ship out of service=
|Ship renamed=
|Ship reclassified=
|Ship refit=
|Ship stricken=
|Ship reinstated=
|Ship homeport=
|Ship identification=
|Ship motto=
|Ship nickname=
|Ship honours=
|Ship honors=
|Ship captured=
|Ship fate=
|Ship status=
|Ship notes=
|Ship badge=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship type=
|Ship tonnage=
|Ship displacement=
|Ship tons burthen=
|Ship length=
|Ship beam=
|Ship height=
|Ship draught=
|Ship draft=
|Ship depth=
|Ship hold depth=
|Ship decks=
|Ship deck clearance=
|Ship ramps=
|Ship ice class=
|Ship power=
|Ship propulsion=
|Ship sail plan=
|Ship speed=
|Ship range=
|Ship endurance=
|Ship test depth=
|Ship boats=
|Ship capacity=
|Ship troops=
|Ship complement=
|Ship crew=
|Ship time to activate=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship armour=
|Ship armor=
|Ship aircraft=
|Ship aircraft facilities=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of all options setup -->
==== Code for ship classes ====
For infoboxes of ship classes, please copy the appropriate example for the type of ship class:
{{collapse top |bg=#CCCCFF |title=Warship classes (except submarines). {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- warship classes -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Built range=
|In commission range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship type=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship propulsion=
|Ship speed=
|Ship range=
|Ship complement=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship armour=
|Ship armor=
|Ship aircraft=
|Ship aircraft facilities=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of warships classes -->
{{collapse top |bg=#CCCCFF |title=Submarine classes. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- submarine classes -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Built range=
|In commission range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship type=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship propulsion=
|Ship speed=
|Ship range=
|Ship endurance=
|Ship test depth=
|Ship complement=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of submarine classes -->
{{collapse top |bg=#CCCCFF |title=Age of sail classes. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- age of sail classes -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Built range=
|In commission range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship type=
|Ship tons burthen=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship hold depth=
|Ship propulsion=
|Ship sail plan=
|Ship complement=
|Ship armament=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of age of sail classes -->
{{collapse top |bg=#CCCCFF |title=Commercial vessel classes. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- commercial vessel classes -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Built range=
|In service range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship type=
|Ship tonnage=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship height=
|Ship draught=
|Ship draft=
|Ship depth=
|Ship decks=
|Ship deck clearance=
|Ship ramps=
|Ship ice class=
|Ship sail plan=
|Ship power=
|Ship propulsion=
|Ship speed=
|Ship capacity=
|Ship crew=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of commercial vessel classes -->
<br>
If none of the above fit, you may use this full setup:
{{collapse top |bg=#CCCCFF |title=Full code for ship classes. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- full code -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Name=
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Cost=
|Built range=
|In service range=
|In commission range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship type=
|Ship tonnage=
|Ship displacement=
|Ship tons burthen=
|Ship length=
|Ship beam=
|Ship height=
|Ship draught=
|Ship draft=
|Ship depth=
|Ship hold depth=
|Ship decks=
|Ship deck clearance=
|Ship ramps=
|Ship ice class=
|Ship power=
|Ship propulsion=
|Ship sail plan=
|Ship speed=
|Ship range=
|Ship endurance=
|Ship test depth=
|Ship boats=
|Ship capacity=
|Ship troops=
|Ship complement=
|Ship crew=
|Ship time to activate=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship armour=
|Ship armor=
|Ship aircraft=
|Ship aircraft facilities=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of full code -->
=== Parameters ===
{{Further information|Template:Infobox ship begin/Usage guide}}
Most fields are self-explanatory, but here are some tips (see the [[Template:Infobox ship begin/Usage guide|usage guide]] for a complete explanation of all parameter fields):
#'''Ship image''' If your article does not have an image in this field, the ship will automatically be listed at the hidden category [[:Category:Ship infoboxes without an image]]. Editors can use the category to easily see a list of infoboxes where no image is attached and work to find pictures.
#'''Ship caption''' and '''image alt''', the caption and alt for the ship's picture, should be left blank if no extra information about the picture is available; don't just fill in the ship's name.
#'''Ship country''' is necessary when a ship served under multiple countries, but not really necessary otherwise.
#'''Ship class''' should include both the class and the type of ship. For example, [[Balao class submarine|''Balao''-class]] [[diesel-electric]] [[submarine]] provides complete information. It can be replaced with '''Ship type''', which displays as "Type:", for ships that aren't members of a class.
#'''Ship name''' is necessary when a ship served under multiple names, but not really necessary otherwise.
#'''Ship fate''' and '''Ship status''' generally shouldn't both be filled in. Whichever one sounds most appropriate for the situation should be filled in. Use Ship fate when the ship sank or was scrapped, and use Ship status when the ship is active, kept in reserve, or currently a museum.
#'''Ship displacement''' and '''Ship tonnage''' are not the same thing. [[Displacement (fluid)|Displacement]] is the mass of a ship in a particular condition, like when it's fully loaded for battle. It is generally used for military vessels. [[Tonnage]] is a measurement of the cargo capacity of a vessel and isn't exactly correlated with weight: a ship of a particular tonnage will have a different mass depending on whether it's full of grain or iron. Entries in either parameter need to specifically identify the units in which they are being measured, such as long tons, metric tons or tonnes (unacceptable in articles using American English, use metric tons) or gross register tons or whatever. If possible, use templates such as {{Template|GT}}, {{Template|NetT}} and {{Template|DWT}}.
==== Alternative spellings ====
Some fields provide alternative spellings and should never both be filled in:
# "Ship honors" and "Ship honours"
# "Ship draft" and "Ship draught"
# "Ship armor" and "Ship armour"
===Removing extra fields===
It's generally a good idea not to remove fields, because another editor might be able to provide the information later. However, in the case of mutually exclusive fields, like "Ship armor" and "Ship armour", the unused field can be removed if desired. Also, if a section is repeated (to show multiple periods in commission, for example), fields that are inappropriate to duplicate can be removed if desired. Keep in mind that a ship from the Age of Sail would not need the fields for aircraft or electronic warfare instruments and conversely an aircraft carrier would not need the fields for a sail plan. A surface ship would not require fields for submarines etc.
=== Special capabilities ===
==== Repeating sections ====
This infobox allows you to repeat sections. To repeat, just make a copy of the section to be repeated. You can repeat the Image, Career, or Characteristics sections. Here is an example, with extra fields removed for clarity:
{|{{Infobox ship begin |infobox caption=USS ''Bang'' (SS-385)}}
{{Infobox ship image
| Ship image=Uss bang.jpg
| Ship caption=
}}
{{Infobox ship career
| Ship country=U.S.
| Ship flag={{USN flag|1972}}
| Ship name=USS ''Bang'' (SS-385)
| Ship laid down=30 April 1943
| Ship launched=30 August 1943
| Ship commissioned=4 December 1943
| Ship decommissioned=1 October 1972
| Ship struck=18 November 1974
| Ship fate=Transferred to Spain, 1 October 1972
}}
{{Infobox ship career
| Ship country=Spain
| Ship flag={{shipboxflag|Spain}}
| Ship name=SPS ''Cosme Garcia'' (S34)
| Ship acquired=1 October 1972
| Ship fate=scrapped 1983
}}
{{Infobox ship characteristics
| Header caption=
| Ship displacement=*1,526 tons surfaced
*2,391 tons
| Ship length={{convert|311|ft|8|in|m|2|abbr=on}}
| Ship beam={{convert|27|ft|3|in|m|2|abbr=on}}
| Ship complement=66
}}
|}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
| Ship image=Uss bang.jpg
| Ship caption=
}}
{{Infobox ship career
| Ship country=US
| Ship flag={{USN flag|1972}}
| Ship name=USS ''Bang'' (SS-385)
| Ship laid down=30 April 1943
| Ship launched=30 August 1943
| Ship commissioned=4 December 1943
| Ship decommissioned=1 October 1972
| Ship struck=18 November 1974
| Ship fate=Transferred to Spain, 1 October 1972
}}
{{Infobox ship career
| Ship country=Spain
| Ship flag={{shipboxflag|Spain}}
| Ship name=SPS ''Cosme Garcia'' (S34)
| Ship acquired=1 October 1972
| Ship fate=scrapped 1983
}}
{{Infobox ship characteristics
| Header caption=
| Ship displacement=*1,526 tons surfaced
*2,391 tons
| Ship length=311 ft 8 in (95 m)
| Ship beam=27 ft 3 in (8.3 m)
| Ship complement=66
}}
|}</syntaxhighlight>
{{-}}
==== Hiding section headers ====
It is possible to hide the headers for the Career and General Characteristics sections, in order to repeat fields. For example, a ship might have been commissioned, decommissioned, recommissioned, and decommissioned again. To have the second commission and decommission dates, use additional a second Infobox ship career template with its header hidden, like this:
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
| Ship image=USS Wisconsin (BB-64) underway at sea, circa 1988-1991 (NH 97206-KN).jpg
| Ship caption=USS ''Wisconsin'' at sea, circa 1990
| image alt=USS ''Wisconsin'' at sea, circa 1990
}}
{{Infobox ship career
| Hide header=
| Ship caption=US
| Ship flag={{USN flag|1992}}
| Ship laid down=25 January 1941
| Ship launched=7 December 1943
| Ship commissioned=16 April 1944
| Ship decommissioned=1 July 1948
}}
{{Infobox ship career
| Hide header=yes
| Ship recommissioned=3 March 1951
| Ship decommissioned=8 March 1958
}}
{{Infobox ship career
| Hide header=yes
| Ship recommissioned=1 August 1986
| Ship decommissioned=30 September 1991
| Ship struck=17 March 2006
| Ship fate=[[Museum ship]]
}}
{{Infobox ship characteristics
| Hide header=
| Header caption=(1943)
| Ship displacement=45,000 tons
| Ship length=887.2 ft (270 m)
| Ship beam=108.2 ft (33 m)
| Ship draft=28.9 ft (8.8 m)
| Ship speed=33 knots (61 km/h)
| Ship complement=1,921 officers and men
| Ship armament=big guns
}}
|}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
| Ship image=USS Wisconsin (BB-64) underway at sea, circa 1988-1991 (NH 97206-KN).jpg
| Ship caption=USS ''Wisconsin'' at sea, circa 1990
| image alt=USS ''Wisconsin'' at sea, circa 1990
}}
{{Infobox ship career
| Hide header=
| Ship caption=(US)
| Ship flag={{USN flag|1992}}
| Ship laid down=25 January 1941
| Ship launched=7 December 1943
| Ship commissioned=16 April 1944
| Ship decommissioned=1 July 1948
}}
{{Infobox ship career
| Hide header=yes
| Ship recommissioned=3 March 1951
| Ship decommissioned=8 March 1958
}}
{{Infobox ship career
| Hide header=yes
| Ship recommissioned=1 August 1986
| Ship decommissioned=30 September 1991
| Ship struck=17 March 2006
| Ship fate=[[Museum ship]]
}}
{{Infobox ship characteristics
| Hide header=
| Header caption=(1943)
| Ship displacement=45,000 tons
| Ship length=887.2 ft (270 m)
| Ship beam=108.2 ft (33 m)
| Ship draft=28.9 ft (8.8 m)
| Ship speed=33 knots (61 km/h)
| Ship complement=1,921 officers and men
| Ship armament=big guns
}}
|}</syntaxhighlight>
{{clear}}
==== Header captions ====
The General Characteristics section can be given a caption using the '''Header caption''' field. See the USS Wisconsin example above, which has a header caption of (1943) to indicate that the characteristics provided are as of 1943.
{{-}}
=== Custom fields ===
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
|Ship image=Uss west virginia bb.jpg
|Ship caption=''West Virginia'' in San Francisco Bay, circa 1934.
|image alt=''West Virginia'' in San Francisco Bay, circa 1934.
}}
{{Infobox ship career
| Hide header=
| Ship caption=US
| Ship flag={{USN flag|1947}}
| Ship ordered=5 December 1916
| Ship laid down=12 April 1920
| Ship launched=17 November 1921
| Ship commissioned=1 December 1923
}}
|-
| Sunk:
|7 December 1941
|-
|Raised:
|17 May 1942
{{Infobox ship career
| Hide header=yes
| Ship decommissioned=9 January 1947
| Ship fate=sold for scrap
| Ship struck=1 March 1959
| Ship nickname="Wee Vee"
}}
{{Infobox ship characteristics
| Hide header=
| Ship displacement=33,590 tons
| Ship length=624 ft (190 m)
| Ship beam=97.3 ft (29.6 m)
| Ship draft=30.5 ft (9.3 m)
| Ship speed=21.0 knots (39 km/h)
| Ship complement=1,407 officers and men
| Ship armament=big guns
}}
|}
It is possible to add custom fields to the infobox using standard [[Help:Table|Wiki table syntax]]. This is not encouraged, because infoboxes are intended to standardize the appearance of ship articles, but it can be done if needed. See the below example, where "Sunk:" and "Raised:" fields are added to the ship's career:
<syntaxhighlight lang="wikitext" style="overflow:auto">
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
|Ship image=Uss west virginia bb.jpg
|Ship caption=''West Virginia'' in San Francisco Bay, circa 1934.
|image alt=''West Virginia'' in San Francisco Bay, circa 1934.
}}
{{Infobox ship career
| Hide header=
| Ship caption=US
| Ship flag={{USN flag|1947}}
| Ship ordered=5 December 1916
| Ship laid down=12 April 1920
| Ship launched=17 November 1921
| Ship commissioned=1 December 1923
}}
|-
| Sunk:
|7 December 1941
|-
|Raised:
|17 May 1942
{{Infobox ship career
| Hide header=yes
| Ship decommissioned=9 January 1947
| Ship fate=sold for scrap
| Ship struck=1 March 1959
| Ship nickname="Wee Vee"
}}
{{Infobox ship characteristics
| Hide header=
| Ship displacement=33,590 tons
| Ship length=624 ft (190 m)
| Ship beam=97.3 ft (29.6 m)
| Ship draft=30.5 ft (9.3 m)
| Ship speed=21.0 knots (39 km/h)
| Ship complement=1,407 officers and men
| Ship armament=big guns
}}
|}</syntaxhighlight><!--
--><includeonly>{{Sandbox other||
{{#ifeq:{{SUBPAGENAME}}|doc||
{{#ifeq:{{NAMESPACE}}|{{NS:10}}|
<!-- ADD CATEGORIES BELOW THIS LINE -->
[[Category:Water transport infobox templates|Ship table]]
[[Category:Military ship infobox templates|Ship table]]
[[Category:Ship templates|Ship table]]
}}
}}
}}</includeonly>
e0286ecc255848ee0ede5c58fcde20b2f7c9d30e
Module:Transclusion count/data/D
828
139
281
2023-10-01T05:37:06Z
w>Ahechtbot
0
[[Wikipedia:BOT|Bot]]: Updated page.
Scribunto
text/plain
return {
["D&D"] = 3900,
["D&D_to-do"] = 5600,
["D-da"] = 2600,
["DANFS"] = 8400,
["DC-Comics-trademark-copyright"] = 2100,
["DCS_Sri_Lanka"] = 2100,
["DDR"] = 2800,
["DEC"] = 8700,
["DECADE"] = 283000,
["DEN"] = 6800,
["DEU"] = 17000,
["DMC"] = 58000,
["DMCA"] = 2350000,
["DNB"] = 8800,
["DNB-Portal"] = 2100,
["DNB_portal"] = 3800,
["DNK"] = 7800,
["DNZB"] = 3600,
["DOM"] = 2100,
["DOWs"] = 2700,
["DRV_links"] = 3600,
["DWT"] = 2300,
["DYKC"] = 6700,
["DYKF"] = 2100,
["DYK_blue"] = 3400,
["DYK_checklist"] = 14000,
["DYK_conditions"] = 67000,
["DYK_files"] = 2100,
["DYK_header"] = 34000,
["DYK_nompage_links"] = 79000,
["DYK_talk"] = 103000,
["DYK_talk/date"] = 103000,
["DYK_tools"] = 52000,
["DYK_tools/styles.css"] = 52000,
["DYKfile"] = 12000,
["DZA"] = 2800,
["Dab"] = 18000,
["Dagger"] = 18000,
["Dashboard.wikiedu.org_assignment"] = 14000,
["Dashboard.wikiedu.org_bibliography/guide"] = 6700,
["Dashboard.wikiedu.org_course_header"] = 6200,
["Dashboard.wikiedu.org_course_header/edit-note"] = 6200,
["Dashboard.wikiedu.org_draft_template/about_this_sandbox"] = 10000,
["Dashboard.wikiedu.org_evaluate_article/guide"] = 8200,
["Dashboard.wikiedu.org_peer_review/guide"] = 12000,
["Dashboard.wikiedu.org_sandbox"] = 96000,
["Dashboard.wikiedu.org_student_editor"] = 84000,
["Dashboard.wikiedu.org_student_program_sandbox"] = 95000,
["Dashboard.wikiedu.org_talk_course_link"] = 85000,
["Dashboard.wikiedu.org_user_talk"] = 2200,
["Date"] = 42000,
["Date-mf"] = 39000,
["Date_table_sorting"] = 39000,
["Dated_maintenance_category"] = 2410000,
["Dated_maintenance_category_(articles)"] = 2350000,
["Dated_maintenance_category_by_type_(articles)"] = 22000,
["Davis_Cup_player"] = 2500,
["Day+1"] = 6900,
["Day-1"] = 8300,
["Dbox"] = 3000,
["Dda"] = 5200,
["Dead_YouTube_link"] = 2700,
["Dead_Youtube_links"] = 2200,
["Dead_link"] = 287000,
["Deadlink"] = 3100,
["Death-date"] = 11000,
["Death-date_and_age"] = 10000,
["Death_date"] = 9200,
["Death_date_and_age"] = 389000,
["Death_date_and_given_age"] = 2700,
["Death_date_text"] = 11000,
["Death_year_and_age"] = 16000,
["Death_year_category_header"] = 2000,
["Decade"] = 2100,
["Decade_link"] = 32000,
["Decimals"] = 3100,
["Decline"] = 2500,
["Declined"] = 3200,
["Decrease"] = 35000,
["Define"] = 4400,
["Deg2DMS"] = 3400,
["Deletion_review_log_header"] = 5700,
["Deletion_review_log_header/Core"] = 5700,
["Delink"] = 1990000,
["Delink_question_hyphen-minus"] = 295000,
["Delrevxfd"] = 3600,
["Democratic_Party_(US)/meta/shading"] = 15000,
["Description_missing"] = 7100,
["Designation/abbreviation"] = 8300,
["Designation/color"] = 76000,
["Designation/colour"] = 79000,
["Designation/colour2"] = 18000,
["Designation/divbox"] = 30000,
["Designation/text"] = 42000,
["Designation_list"] = 5400,
["Details"] = 4500,
["DetailsLink"] = 5900,
["Detect_singular"] = 202000,
["Deutsche_Bahn_station_codes"] = 2200,
["DfE_performance_tables"] = 4500,
["Diff"] = 30000,
["Diff2"] = 12000,
["Digits"] = 21000,
["Directories_box"] = 3200,
["Disamb"] = 2200,
["Disambig"] = 63000,
["Disambig-Class"] = 12000,
["DisambigProj"] = 12000,
["DisambigProject"] = 150000,
["Disambigproject"] = 5800,
["Disambiguation"] = 218000,
["Disambiguation/cat"] = 218000,
["Disambiguation_page_short_description"] = 354000,
["Discogs_artist"] = 17000,
["Discogs_master"] = 12000,
["Discogs_release"] = 3100,
["Discussion_bottom"] = 12000,
["Discussion_top"] = 13000,
["DisestcatCountry"] = 9500,
["DisestcatCountry/core"] = 9500,
["DisestcatCountryDecade"] = 2600,
["DisestcatUSstate"] = 4900,
["DisestcatUSstate/core"] = 4900,
["Disputed"] = 2200,
["Distinguish"] = 98000,
["Disused_Rail_Start"] = 3900,
["Disused_rail_start"] = 4300,
["Disused_style"] = 4700,
["Div_col"] = 400000,
["Div_col/styles.css"] = 401000,
["Div_col_end"] = 302000,
["Div_col_start"] = 2900,
["Div_end"] = 2700,
["Divbox"] = 347000,
["Divbox/styles.css"] = 370000,
["Dividing_line"] = 4000,
["Dmbox"] = 461000,
["Dmbox/styles.css"] = 461000,
["Do_not_move_to_Commons"] = 16000,
["Doc"] = 3600,
["Documentation"] = 121000,
["Documentation_subpage"] = 95000,
["Dog_opentask"] = 3500,
["Doi"] = 26000,
["Doing"] = 3600,
["Don't_edit_this_line"] = 108000,
["Don't_edit_this_line_always_display"] = 479000,
["Don't_edit_this_line_extinct"] = 479000,
["Don't_edit_this_line_link_target"] = 479000,
["Don't_edit_this_line_link_text"] = 479000,
["Don't_edit_this_line_parent"] = 479000,
["Don't_edit_this_line_rank"] = 479000,
["Don't_edit_this_line_refs"] = 108000,
["Don't_edit_this_line_same_as"] = 479000,
["Done"] = 103000,
["Doppelganger"] = 2800,
["Double+single"] = 2800,
["Double-dagger"] = 19000,
["Dr"] = 3400,
["Dr-logno"] = 3400,
["Dr-make"] = 3500,
["Dr-yr"] = 3400,
["Draft"] = 4300,
["Draft_article"] = 6400,
["Draft_article_check"] = 6500,
["Draft_categories"] = 8100,
["Draft_other"] = 112000,
["Draft_topics"] = 24000,
["Drafts_moved_from_mainspace"] = 8700,
["Draw"] = 3900,
["Draw_key"] = 18000,
["Draw_links"] = 13000,
["Drep"] = 3500,
["Drugbankcite"] = 4300,
["Drugbox"] = 7600,
["Drugs.com"] = 3800,
["Ds/talk_notice"] = 6400,
["Dts"] = 38000,
["Dubious"] = 8100,
["Duck"] = 2900,
["Dummytab"] = 5000,
["Duration"] = 38000,
["Dutch_municipality"] = 2700,
["Dyktalk"] = 42000,
["Dynamic_list"] = 10000,
["Module:DYK_checklist"] = 14000,
["Module:DYK_checklist/data"] = 14000,
["Module:DYK_nompage_links"] = 79000,
["Module:Data"] = 149000,
["Module:Date"] = 1380000,
["Module:DateI18n"] = 66000,
["Module:Date_table_sorting"] = 39000,
["Module:DecodeEncode"] = 117000,
["Module:Delink"] = 2080000,
["Module:Detect_singular"] = 1530000,
["Module:Disambiguation"] = 15800000,
["Module:Disambiguation/templates"] = 15400000,
["Module:Distinguish"] = 98000,
["Module:Documentation"] = 167000,
["Module:Documentation/config"] = 167000,
["Module:Documentation/styles.css"] = 167000,
["Module:Draft_topics"] = 24000,
["Module:Duration"] = 238000,
}
8f683619a2978bf72bfba8daad66e905645f9921
Module:Transclusion count/data/I
828
70
143
2023-10-01T05:37:56Z
Template>Ahechtbot
0
[[Wikipedia:BOT|Bot]]: Updated page.
Scribunto
text/plain
return {
["IAAF_name"] = 2100,
["IAST"] = 6400,
["IBDB_name"] = 9100,
["ICD10"] = 4700,
["ICD9"] = 4400,
["ICS"] = 2900,
["IDN"] = 3400,
["IMDb_episode"] = 10000,
["IMDb_episodes"] = 2700,
["IMDb_name"] = 154000,
["IMDb_title"] = 189000,
["IMO_Number"] = 4100,
["IMSLP"] = 8300,
["INA"] = 2100,
["IND"] = 7600,
["INR"] = 6500,
["INRConvert"] = 5700,
["INRConvert/CurrentRate"] = 5600,
["INRConvert/USD"] = 5600,
["INRConvert/out"] = 5600,
["IOC_profile"] = 5200,
["IP"] = 2600,
["IPA"] = 142000,
["IPA-de"] = 8100,
["IPA-es"] = 7900,
["IPA-fr"] = 44000,
["IPA-it"] = 6000,
["IPA-nl"] = 3900,
["IPA-pl"] = 4100,
["IPA-pt"] = 3300,
["IPA-ru"] = 2700,
["IPA-sl"] = 6900,
["IPA-th"] = 3000,
["IPA_audio_link"] = 3500,
["IPA_link"] = 3500,
["IPAc-cmn"] = 2300,
["IPAc-en"] = 48000,
["IPAc-pl"] = 51000,
["IPC_athlete"] = 2800,
["IPSummary"] = 78000,
["IP_summary"] = 79000,
["IPtalk"] = 18000,
["IPuser"] = 7100,
["IPvandal"] = 2700,
["IRC"] = 7300,
["IRI"] = 2300,
["IRL"] = 5500,
["IRN"] = 3600,
["ISBN"] = 462000,
["ISBN?"] = 2100,
["ISBNT"] = 39000,
["ISBN_missing"] = 2600,
["ISFDB_name"] = 4100,
["ISFDB_title"] = 4600,
["ISL"] = 2100,
["ISO_15924/script-example-character"] = 2800,
["ISO_15924/wp-article"] = 2800,
["ISO_15924/wp-article/format"] = 2800,
["ISO_15924/wp-article/label"] = 2700,
["ISO_3166_code"] = 519000,
["ISO_3166_name"] = 16000,
["ISO_639_name"] = 8100,
["ISP"] = 5300,
["ISR"] = 4900,
["ISSN"] = 12000,
["ISSN_link"] = 30000,
["ISTAT"] = 8100,
["ISU_figure_skater"] = 2500,
["ITA"] = 17000,
["ITF"] = 6300,
["ITF_profile"] = 9000,
["ITIS"] = 4400,
["ITN_talk"] = 10000,
["ITN_talk/date"] = 10000,
["IUCN_banner"] = 15000,
["I_sup"] = 4600,
["Iaaf_name"] = 7200,
["Ice_hockey"] = 19000,
["Ice_hockey_stats"] = 17000,
["Icehockeystats"] = 12000,
["Icon"] = 581000,
["If"] = 272000,
["If_all"] = 6400,
["If_between"] = 3800,
["If_both"] = 155000,
["If_empty"] = 3660000,
["If_first_display_both"] = 73000,
["If_in_page"] = 10000,
["If_last_display_both"] = 30000,
["If_preview"] = 58000,
["If_then_show"] = 289000,
["Ifempty"] = 4000,
["Ifeq"] = 16000,
["Iferror_then_show"] = 3300,
["Ifexist_not_redirect"] = 1300000,
["Ifnotempty"] = 14000,
["Ifnumber"] = 36000,
["Ifsubst"] = 446000,
["Ih"] = 7500,
["Ill"] = 117000,
["Illm"] = 6700,
["Image_frame"] = 4900,
["Image_label"] = 4500,
["Image_label_begin"] = 3800,
["Image_label_end"] = 3800,
["Image_label_small"] = 2600,
["Image_needed"] = 4500,
["Image_other"] = 272000,
["Image_requested"] = 167000,
["Image_requested/Category_helper"] = 159000,
["Imbox"] = 917000,
["Imdb_name"] = 5400,
["Imdb_title"] = 4000,
["Import_style"] = 11000,
["Import_style/inputbox.css"] = 11000,
["Importance"] = 5640000,
["Importance/colour"] = 5660000,
["Importance_mask"] = 10400000,
["Improve_categories"] = 7000,
["Improve_documentation"] = 2400,
["In_class"] = 5900,
["In_lang"] = 356000,
["In_progress"] = 3200,
["In_string"] = 75000,
["In_title"] = 19000,
["Inactive_WikiProject_banner"] = 205000,
["Inactive_userpage_blanked"] = 4900,
["Include-USGov"] = 29000,
["Incomplete_list"] = 23000,
["Inconclusive"] = 2100,
["Increase"] = 43000,
["Incumbent_pope"] = 4300,
["Indent"] = 4400,
["IndexFungorum"] = 2200,
["Indian_English"] = 4300,
["Indian_Rupee"] = 10000,
["Indian_railway_code"] = 3200,
["Inflation"] = 21000,
["Inflation-fn"] = 5400,
["Inflation-year"] = 4500,
["Inflation/IN/startyear"] = 5600,
["Inflation/UK"] = 4400,
["Inflation/UK/dataset"] = 4400,
["Inflation/UK/startyear"] = 4400,
["Inflation/US"] = 12000,
["Inflation/US-GDP"] = 2400,
["Inflation/US-GDP/dataset"] = 2400,
["Inflation/US-GDP/startyear"] = 2400,
["Inflation/US/dataset"] = 12000,
["Inflation/US/startyear"] = 12000,
["Inflation/fn"] = 6200,
["Inflation/year"] = 25000,
["Info"] = 7300,
["Infobox"] = 3230000,
["Infobox/Columns"] = 2400,
["Infobox/mobileviewfix.css"] = 147000,
["Infobox3cols"] = 17000,
["Infobox_AFL_biography"] = 14000,
["Infobox_Aircraft_Begin"] = 5300,
["Infobox_Aircraft_Type"] = 4700,
["Infobox_Athletics_Championships"] = 2700,
["Infobox_Australian_place"] = 15000,
["Infobox_CFL_biography"] = 2200,
["Infobox_COA_wide"] = 3200,
["Infobox_Canada_electoral_district"] = 2500,
["Infobox_Canadian_Football_League_biography"] = 5700,
["Infobox_Canadian_Football_League_biography/position"] = 5700,
["Infobox_Chinese"] = 20000,
["Infobox_Chinese/Chinese"] = 2700,
["Infobox_Chinese/Footer"] = 8700,
["Infobox_Chinese/Header"] = 8700,
["Infobox_Chinese/Korean"] = 17000,
["Infobox_Christian_leader"] = 18000,
["Infobox_French_commune"] = 38000,
["Infobox_GAA_player"] = 2700,
["Infobox_Gaelic_games_player"] = 5000,
["Infobox_German_location"] = 13000,
["Infobox_German_place"] = 14000,
["Infobox_Grand_Prix_race_report"] = 2000,
["Infobox_Greece_place"] = 2800,
["Infobox_Greek_Dimos"] = 2800,
["Infobox_Hindu_temple"] = 2400,
["Infobox_Indian_constituency"] = 4700,
["Infobox_Indian_constituency/defaultdata"] = 4700,
["Infobox_Italian_comune"] = 8100,
["Infobox_Korean_name"] = 15000,
["Infobox_Korean_name/categories"] = 15000,
["Infobox_MLB_yearly"] = 3100,
["Infobox_NASCAR_race_report"] = 2200,
["Infobox_NCAA_team_season"] = 18000,
["Infobox_NFL_biography"] = 28000,
["Infobox_NFL_player"] = 7700,
["Infobox_NFL_team_season"] = 3900,
["Infobox_NRHP"] = 72000,
["Infobox_NRHP/conv"] = 18000,
["Infobox_NRHP/locmapin2region"] = 66000,
["Infobox_Officeholder"] = 4800,
["Infobox_Olympic_event"] = 7300,
["Infobox_Olympic_event/games_text"] = 7300,
["Infobox_Paralympic_event"] = 2600,
["Infobox_Paralympic_event/games_text"] = 2600,
["Infobox_Politician"] = 2200,
["Infobox_Romanian_subdivision"] = 3200,
["Infobox_Russian_district"] = 2000,
["Infobox_Russian_inhabited_locality"] = 4500,
["Infobox_SCOTUS_case"] = 3700,
["Infobox_Site_of_Special_Scientific_Interest"] = 2000,
["Infobox_Swiss_town"] = 2800,
["Infobox_Switzerland_municipality"] = 2900,
["Infobox_Turkey_place"] = 19000,
["Infobox_U.S._county"] = 3000,
["Infobox_U.S._county/district"] = 3000,
["Infobox_UK_constituency"] = 2100,
["Infobox_UK_constituency/year"] = 2100,
["Infobox_UK_legislation"] = 3300,
["Infobox_UK_place"] = 26000,
["Infobox_UK_place/NoDialCode"] = 8000,
["Infobox_UK_place/NoPostCode"] = 3100,
["Infobox_UK_place/area"] = 2400,
["Infobox_UK_place/dist"] = 2500,
["Infobox_UK_place/local"] = 26000,
["Infobox_UK_place/styles.css"] = 26000,
["Infobox_UN_resolution"] = 2300,
["Infobox_US_Supreme_Court_case"] = 3800,
["Infobox_US_Supreme_Court_case/courts"] = 3800,
["Infobox_Wikipedia_user"] = 9800,
["Infobox_YouTube_personality"] = 2700,
["Infobox_YouTube_personality/styles.css"] = 2700,
["Infobox_academic"] = 14000,
["Infobox_aircraft_begin"] = 14000,
["Infobox_aircraft_occurrence"] = 2300,
["Infobox_aircraft_type"] = 12000,
["Infobox_airline"] = 4600,
["Infobox_airport"] = 15000,
["Infobox_airport/datatable"] = 15000,
["Infobox_album"] = 162000,
["Infobox_album/color"] = 192000,
["Infobox_album/link"] = 162000,
["Infobox_anatomy"] = 4500,
["Infobox_ancient_site"] = 5400,
["Infobox_animanga/Footer"] = 6800,
["Infobox_animanga/Header"] = 6800,
["Infobox_animanga/Print"] = 5500,
["Infobox_animanga/Video"] = 4700,
["Infobox_architect"] = 3700,
["Infobox_artist"] = 28000,
["Infobox_artist_discography"] = 5900,
["Infobox_artwork"] = 11000,
["Infobox_athlete"] = 2800,
["Infobox_automobile"] = 8400,
["Infobox_award"] = 13000,
["Infobox_badminton_player"] = 3200,
["Infobox_baseball_biography"] = 28000,
["Infobox_baseball_biography/style"] = 28000,
["Infobox_baseball_biography/styles.css"] = 28000,
["Infobox_basketball_biography"] = 21000,
["Infobox_basketball_biography/style"] = 21000,
["Infobox_basketball_club"] = 3000,
["Infobox_beauty_pageant"] = 2400,
["Infobox_bilateral_relations"] = 4400,
["Infobox_body_of_water"] = 18000,
["Infobox_book"] = 52000,
["Infobox_boxer"] = 5700,
["Infobox_bridge"] = 6000,
["Infobox_building"] = 27000,
["Infobox_character"] = 7600,
["Infobox_chess_biography"] = 3900,
["Infobox_chess_player"] = 3200,
["Infobox_church"] = 15000,
["Infobox_church/denomination"] = 15000,
["Infobox_church/font_color"] = 15000,
["Infobox_civil_conflict"] = 2400,
["Infobox_civilian_attack"] = 5500,
["Infobox_college_coach"] = 12000,
["Infobox_college_football_game"] = 2100,
["Infobox_college_sports_team_season"] = 40000,
["Infobox_college_sports_team_season/link"] = 40000,
["Infobox_college_sports_team_season/name"] = 40000,
["Infobox_college_sports_team_season/succession"] = 40000,
["Infobox_college_sports_team_season/team"] = 40000,
["Infobox_comic_book_title"] = 3000,
["Infobox_comics_character"] = 3600,
["Infobox_comics_creator"] = 3500,
["Infobox_comics_creator/styles.css"] = 3500,
["Infobox_company"] = 83000,
["Infobox_computing_device"] = 2300,
["Infobox_concert"] = 3300,
["Infobox_constituency"] = 5400,
["Infobox_country"] = 6400,
["Infobox_country/formernext"] = 6000,
["Infobox_country/imagetable"] = 5200,
["Infobox_country/multirow"] = 8300,
["Infobox_country/status_text"] = 2800,
["Infobox_country/styles.css"] = 6500,
["Infobox_country_at_games"] = 15000,
["Infobox_country_at_games/core"] = 15000,
["Infobox_country_at_games/see_also"] = 12000,
["Infobox_court_case"] = 4700,
["Infobox_court_case/images"] = 2400,
["Infobox_cricket_tournament"] = 2300,
["Infobox_cricketer"] = 32000,
["Infobox_cricketer/career"] = 32000,
["Infobox_cricketer/national_side"] = 7500,
["Infobox_criminal"] = 6400,
["Infobox_curler"] = 2600,
["Infobox_cycling_race_report"] = 4500,
["Infobox_cyclist"] = 16000,
["Infobox_dam"] = 5700,
["Infobox_designation_list"] = 20000,
["Infobox_designation_list/entry"] = 17000,
["Infobox_dim"] = 6900,
["Infobox_dim/core"] = 6900,
["Infobox_diocese"] = 3800,
["Infobox_drug"] = 9800,
["Infobox_drug/chemical_formula"] = 9800,
["Infobox_drug/data_page_link"] = 9800,
["Infobox_drug/formatATC"] = 9600,
["Infobox_drug/formatCASnumber"] = 9800,
["Infobox_drug/formatChEBI"] = 9800,
["Infobox_drug/formatChEMBL"] = 9800,
["Infobox_drug/formatChemDBNIAID"] = 9800,
["Infobox_drug/formatChemSpider"] = 9800,
["Infobox_drug/formatCompTox"] = 9800,
["Infobox_drug/formatDrugBank"] = 9800,
["Infobox_drug/formatIUPHARBPS"] = 9800,
["Infobox_drug/formatJmol"] = 9800,
["Infobox_drug/formatKEGG"] = 9800,
["Infobox_drug/formatPDBligand"] = 9100,
["Infobox_drug/formatPubChemCID"] = 9800,
["Infobox_drug/formatPubChemSID"] = 9800,
["Infobox_drug/formatUNII"] = 9800,
["Infobox_drug/legal_status"] = 10000,
["Infobox_drug/licence"] = 9800,
["Infobox_drug/maintenance_categories"] = 9800,
["Infobox_drug/non-ref-space"] = 4200,
["Infobox_drug/pregnancy_category"] = 9800,
["Infobox_drug/title"] = 9800,
["Infobox_election"] = 30000,
["Infobox_election/row"] = 30000,
["Infobox_election/shortname"] = 28000,
["Infobox_enzyme"] = 5100,
["Infobox_ethnic_group"] = 7300,
["Infobox_event"] = 5400,
["Infobox_family"] = 2100,
["Infobox_figure_skater"] = 4200,
["Infobox_film"] = 156000,
["Infobox_film/short_description"] = 152000,
["Infobox_film_awards"] = 2600,
["Infobox_film_awards/link"] = 2600,
["Infobox_film_awards/style"] = 2600,
["Infobox_food"] = 6900,
["Infobox_football_biography"] = 206000,
["Infobox_football_club"] = 27000,
["Infobox_football_club_season"] = 20000,
["Infobox_football_league"] = 2600,
["Infobox_football_league_season"] = 19000,
["Infobox_football_match"] = 5900,
["Infobox_football_tournament_season"] = 8000,
["Infobox_former_subdivision"] = 3300,
["Infobox_former_subdivision/styles.css"] = 3300,
["Infobox_galaxy"] = 2100,
["Infobox_game"] = 2600,
["Infobox_game_score"] = 3400,
["Infobox_gene"] = 13000,
["Infobox_given_name"] = 4000,
["Infobox_golfer"] = 4400,
["Infobox_golfer/highest_ranking"] = 4400,
["Infobox_government_agency"] = 10000,
["Infobox_government_cabinet"] = 2600,
["Infobox_gridiron_football_person"] = 2400,
["Infobox_gridiron_football_person/position"] = 5700,
["Infobox_gymnast"] = 3400,
["Infobox_handball_biography"] = 4900,
["Infobox_historic_site"] = 11000,
["Infobox_horseraces"] = 2600,
["Infobox_hospital"] = 6300,
["Infobox_hospital/care_system"] = 6300,
["Infobox_hospital/lists"] = 6300,
["Infobox_ice_hockey_biography"] = 20000,
["Infobox_ice_hockey_player"] = 19000,
["Infobox_ice_hockey_team"] = 3000,
["Infobox_ice_hockey_team_season"] = 2000,
["Infobox_international_football_competition"] = 5800,
["Infobox_islands"] = 8800,
["Infobox_islands/area"] = 9300,
["Infobox_islands/density"] = 9300,
["Infobox_islands/length"] = 8900,
["Infobox_islands/styles.css"] = 8800,
["Infobox_journal"] = 9700,
["Infobox_journal/Abbreviation_search"] = 9600,
["Infobox_journal/Bluebook_check"] = 9400,
["Infobox_journal/Former_check"] = 9400,
["Infobox_journal/ISO_4_check"] = 9400,
["Infobox_journal/ISSN-eISSN"] = 9500,
["Infobox_journal/Indexing_search"] = 9500,
["Infobox_journal/MathSciNet_check"] = 9400,
["Infobox_journal/NLM_check"] = 9400,
["Infobox_journal/frequency"] = 8600,
["Infobox_lake"] = 4200,
["Infobox_language"] = 9500,
["Infobox_language/family-color"] = 11000,
["Infobox_language/genetic"] = 6500,
["Infobox_language/linguistlist"] = 9500,
["Infobox_language/ref"] = 7100,
["Infobox_legislature"] = 3600,
["Infobox_library"] = 2200,
["Infobox_lighthouse"] = 2600,
["Infobox_lighthouse/light"] = 2600,
["Infobox_locomotive"] = 4900,
["Infobox_magazine"] = 7600,
["Infobox_manner_of_address"] = 3300,
["Infobox_mapframe"] = 80000,
["Infobox_martial_artist"] = 5700,
["Infobox_martial_artist/record"] = 5700,
["Infobox_medal_templates"] = 423000,
["Infobox_medical_condition"] = 10000,
["Infobox_medical_condition_(new)"] = 8200,
["Infobox_medical_details"] = 2000,
["Infobox_military_conflict"] = 22000,
["Infobox_military_installation"] = 9800,
["Infobox_military_person"] = 45000,
["Infobox_military_unit"] = 26000,
["Infobox_mine"] = 2100,
["Infobox_model"] = 2300,
["Infobox_monument"] = 2000,
["Infobox_mountain"] = 28000,
["Infobox_multi-sport_competition_event"] = 2400,
["Infobox_museum"] = 10000,
["Infobox_musical_artist"] = 121000,
["Infobox_musical_artist/color"] = 121000,
["Infobox_musical_artist/hCard_class"] = 313000,
["Infobox_musical_composition"] = 2900,
["Infobox_name"] = 7400,
["Infobox_name_module"] = 7000,
["Infobox_newspaper"] = 9700,
["Infobox_nobility"] = 2500,
["Infobox_noble"] = 7300,
["Infobox_officeholder"] = 219000,
["Infobox_officeholder/office"] = 224000,
["Infobox_official_post"] = 8100,
["Infobox_organization"] = 36000,
["Infobox_pageant_titleholder"] = 2900,
["Infobox_park"] = 7500,
["Infobox_person"] = 474000,
["Infobox_person/Wikidata"] = 4700,
["Infobox_person/height"] = 103000,
["Infobox_person/length"] = 7000,
["Infobox_person/weight"] = 66000,
["Infobox_philosopher"] = 3400,
["Infobox_planet"] = 4700,
["Infobox_play"] = 3900,
["Infobox_political_party"] = 14000,
["Infobox_power_station"] = 3000,
["Infobox_prepared_food"] = 3100,
["Infobox_professional_wrestler"] = 4300,
["Infobox_professional_wrestling_event"] = 2700,
["Infobox_protected_area"] = 14000,
["Infobox_protein_family"] = 2100,
["Infobox_publisher"] = 2400,
["Infobox_racehorse"] = 5500,
["Infobox_racing_driver"] = 3900,
["Infobox_racing_driver_series_section"] = 2000,
["Infobox_radio_station"] = 22000,
["Infobox_rail"] = 2900,
["Infobox_rail_line"] = 7300,
["Infobox_rail_service"] = 2900,
["Infobox_rail_service/doc"] = 2900,
["Infobox_reality_competition_season"] = 3500,
["Infobox_record_label"] = 4000,
["Infobox_recurring_event"] = 6400,
["Infobox_religious_biography"] = 5300,
["Infobox_religious_building"] = 12000,
["Infobox_religious_building/color"] = 17000,
["Infobox_restaurant"] = 2900,
["Infobox_river"] = 30000,
["Infobox_river/calcunit"] = 30000,
["Infobox_river/discharge"] = 30000,
["Infobox_river/row-style"] = 30000,
["Infobox_river/source"] = 30000,
["Infobox_road"] = 24000,
["Infobox_road/meta/mask/category"] = 24000,
["Infobox_road/meta/mask/country"] = 24000,
["Infobox_road/styles.css"] = 25000,
["Infobox_road_small"] = 2300,
["Infobox_rockunit"] = 6400,
["Infobox_royalty"] = 22000,
["Infobox_royalty/short_description"] = 12000,
["Infobox_rugby_biography"] = 16000,
["Infobox_rugby_biography/correct_date"] = 16000,
["Infobox_rugby_biography/depcheck"] = 15000,
["Infobox_rugby_league_biography"] = 9900,
["Infobox_rugby_league_biography/PLAYER"] = 9800,
["Infobox_rugby_team"] = 2600,
["Infobox_sailboat_specifications"] = 2300,
["Infobox_saint"] = 5000,
["Infobox_school"] = 38000,
["Infobox_school/short_description"] = 38000,
["Infobox_school_district"] = 5700,
["Infobox_school_district/styles.css"] = 5700,
["Infobox_scientist"] = 48000,
["Infobox_service_record"] = 2600,
["Infobox_settlement"] = 562000,
["Infobox_settlement/areadisp"] = 238000,
["Infobox_settlement/columns"] = 94000,
["Infobox_settlement/columns/styles.css"] = 94000,
["Infobox_settlement/densdisp"] = 437000,
["Infobox_settlement/impus"] = 82000,
["Infobox_settlement/lengthdisp"] = 169000,
["Infobox_settlement/link"] = 94000,
["Infobox_settlement/metric"] = 210000,
["Infobox_settlement/pref"] = 293000,
["Infobox_settlement/styles.css"] = 562000,
["Infobox_ship_begin"] = 41000,
["Infobox_ship_career"] = 37000,
["Infobox_ship_characteristics"] = 41000,
["Infobox_ship_class_overview"] = 4100,
["Infobox_ship_image"] = 40000,
["Infobox_shopping_mall"] = 3500,
["Infobox_short_story"] = 2400,
["Infobox_skier"] = 2500,
["Infobox_soap_character"] = 2900,
["Infobox_software"] = 14000,
["Infobox_software/simple"] = 14000,
["Infobox_song"] = 76000,
["Infobox_song/color"] = 76000,
["Infobox_song/link"] = 76000,
["Infobox_spaceflight"] = 3600,
["Infobox_spaceflight/styles.css"] = 3600,
["Infobox_sport_event"] = 2200,
["Infobox_sports_competition_event"] = 17000,
["Infobox_sports_competition_event/medalrow"] = 11000,
["Infobox_sports_league"] = 5000,
["Infobox_sports_season"] = 5400,
["Infobox_sports_team"] = 2200,
["Infobox_sportsperson"] = 106000,
["Infobox_stadium"] = 3500,
["Infobox_station"] = 55000,
["Infobox_station/doc"] = 55000,
["Infobox_station/services"] = 55000,
["Infobox_station/styles.css"] = 55000,
["Infobox_street"] = 3400,
["Infobox_swimmer"] = 9400,
["Infobox_television"] = 57000,
["Infobox_television/Short_description"] = 54000,
["Infobox_television_channel"] = 6200,
["Infobox_television_episode"] = 12000,
["Infobox_television_episode/styles.css"] = 12000,
["Infobox_television_season"] = 9500,
["Infobox_television_station"] = 3700,
["Infobox_tennis_biography"] = 10000,
["Infobox_tennis_event"] = 2500,
["Infobox_tennis_tournament_event"] = 19000,
["Infobox_tennis_tournament_year"] = 9200,
["Infobox_tennis_tournament_year/color"] = 28000,
["Infobox_tennis_tournament_year/footer"] = 28000,
["Infobox_train"] = 2300,
["Infobox_union"] = 2100,
["Infobox_university"] = 26000,
["Infobox_user"] = 2700,
["Infobox_venue"] = 18000,
["Infobox_video_game"] = 28000,
["Infobox_video_game/styles.css"] = 28000,
["Infobox_volleyball_biography"] = 5400,
["Infobox_weapon"] = 7300,
["Infobox_website"] = 7700,
["Infobox_writer"] = 39000,
["Information"] = 101000,
["Information/styles.css"] = 101000,
["Inline_block"] = 4500,
["Inprogress"] = 2400,
["Input_link"] = 32000,
["Instagram"] = 11000,
["Interlanguage_link"] = 155000,
["Interlanguage_link_multi"] = 19000,
["Internet_Archive_author"] = 19000,
["Internet_Archive_film"] = 2500,
["Intitle"] = 12000,
["Invalid_SVG"] = 3600,
["Invalid_SVG/styles.css"] = 3600,
["Iptalk"] = 17000,
["IranCensus2006"] = 47000,
["IranNCSGN"] = 3200,
["Iran_Census_2006"] = 47000,
["Irc"] = 2100,
["Irish_place_name"] = 2600,
["IsIPAddress"] = 38000,
["IsValidPageName"] = 142000,
["Is_country_in_Central_America"] = 13000,
["Is_country_in_the_Caribbean"] = 14000,
["Is_interwiki_link"] = 6100,
["Is_italic_taxon"] = 479000,
["Is_redirect"] = 27000,
["Isbn"] = 7500,
["Isfdb_name"] = 3700,
["Isfdb_title"] = 4400,
["Isnumeric"] = 210000,
["Iso2continent"] = 35000,
["Iso2country"] = 23000,
["Iso2country/article"] = 22000,
["Iso2country/data"] = 23000,
["Iso2nationality"] = 227000,
["Issubst"] = 72000,
["Isu_name"] = 2200,
["Italic_dab2"] = 5300,
["Italic_title"] = 285000,
["Italic_title_prefixed"] = 8700,
["Italics_colon"] = 3800,
["Italictitle"] = 4300,
["Ivm"] = 5700,
["Ivm/styles.css"] = 5700,
["Ivmbox"] = 123000,
["Ivory_messagebox"] = 142000,
["Module:I18n/complex_date"] = 66000,
["Module:IP"] = 131000,
["Module:IPA"] = 142000,
["Module:IPA/data"] = 128000,
["Module:IPA/styles.css"] = 114000,
["Module:IPA_symbol"] = 4800,
["Module:IPA_symbol/data"] = 4800,
["Module:IPAc-en"] = 48000,
["Module:IPAc-en/data"] = 48000,
["Module:IPAc-en/phonemes"] = 48000,
["Module:IPAc-en/pronunciation"] = 48000,
["Module:IPAddress"] = 188000,
["Module:ISO_3166"] = 1040000,
["Module:ISO_3166/data/AT"] = 2500,
["Module:ISO_3166/data/BA"] = 3400,
["Module:ISO_3166/data/CA"] = 2500,
["Module:ISO_3166/data/CN"] = 2100,
["Module:ISO_3166/data/DE"] = 14000,
["Module:ISO_3166/data/ES"] = 3600,
["Module:ISO_3166/data/FR"] = 38000,
["Module:ISO_3166/data/GB"] = 6400,
["Module:ISO_3166/data/GR"] = 3100,
["Module:ISO_3166/data/IN"] = 29000,
["Module:ISO_3166/data/IR"] = 8200,
["Module:ISO_3166/data/National"] = 1040000,
["Module:ISO_3166/data/PL"] = 6700,
["Module:ISO_3166/data/RS"] = 3200,
["Module:ISO_3166/data/RU"] = 25000,
["Module:ISO_3166/data/US"] = 85000,
["Module:ISO_639_name"] = 20000,
["Module:ISOdate"] = 66000,
["Module:Icon"] = 581000,
["Module:Icon/data"] = 581000,
["Module:If_empty"] = 3660000,
["Module:If_in_page"] = 10000,
["Module:If_preview"] = 295000,
["Module:If_preview/configuration"] = 295000,
["Module:If_preview/styles.css"] = 295000,
["Module:Import_style"] = 11000,
["Module:In_lang"] = 357000,
["Module:Indent"] = 4400,
["Module:Infobox"] = 4110000,
["Module:Infobox/dates"] = 69000,
["Module:Infobox/styles.css"] = 4360000,
["Module:Infobox3cols"] = 297000,
["Module:InfoboxImage"] = 4420000,
["Module:Infobox_body_of_water_tracking"] = 18000,
["Module:Infobox_cyclist_tracking"] = 16000,
["Module:Infobox_gene"] = 13000,
["Module:Infobox_mapframe"] = 404000,
["Module:Infobox_military_conflict"] = 22000,
["Module:Infobox_military_conflict/styles.css"] = 22000,
["Module:Infobox_multi-lingual_name"] = 20000,
["Module:Infobox_multi-lingual_name/data"] = 20000,
["Module:Infobox_power_station"] = 3000,
["Module:Infobox_road"] = 25000,
["Module:Infobox_road/browselinks"] = 25000,
["Module:Infobox_road/errors"] = 24000,
["Module:Infobox_road/length"] = 25000,
["Module:Infobox_road/locations"] = 24000,
["Module:Infobox_road/map"] = 25000,
["Module:Infobox_road/route"] = 25000,
["Module:Infobox_road/sections"] = 24000,
["Module:Infobox_television"] = 57000,
["Module:Infobox_television_disambiguation_check"] = 63000,
["Module:Infobox_television_episode"] = 12000,
["Module:Infobox_television_season_disambiguation_check"] = 9000,
["Module:Infobox_television_season_name"] = 9500,
["Module:Internet_Archive"] = 19000,
["Module:IrelandByCountyCatNav"] = 3300,
["Module:Is_infobox_in_lead"] = 377000,
["Module:Is_instance"] = 335000,
["Module:Italic_title"] = 1120000,
["Module:Italic_title2"] = 5300,
}
96976089c1e9db8d200dbe641eaed9ec564df70a
Main Page
0
1
1
2023-10-01T06:16:07Z
MediaWiki default
1
Create main page
wikitext
text/x-wiki
__NOTOC__
== Welcome to {{SITENAME}}! ==
This Main Page was created automatically and it seems it hasn't been replaced yet.
=== For the bureaucrat(s) of this wiki ===
Hello, and welcome to your new wiki! Thank you for choosing Miraheze for the hosting of your wiki, we hope you will enjoy our hosting.
You can immediately start working on your wiki or whenever you want.
Need help? No problem! We will help you with your wiki as needed. To start, try checking out these helpful links:
* [[mw:Special:MyLanguage/Help:Contents|MediaWiki guide]] (e.g. navigation, editing, deleting pages, blocking users)
* [[meta:Special:MyLanguage/FAQ|Miraheze FAQ]]
* [[meta:Special:MyLanguage/Request features|Request settings changes on your wiki]]. (Extensions, Skin and Logo/Favicon changes should be done through [[Special:ManageWiki]] on your wiki, see [[meta:Special:MyLanguage/ManageWiki|ManageWiki]] for more information.)
==== I still don't understand X! ====
Well, that's no problem. Even if something isn't explained in the documentation/FAQ, we are still happy to help you. You can find us here:
* [[meta:Special:MyLanguage/Help center|On our own Miraheze wiki]]
* On [[phab:|Phabricator]]
* On [https://miraheze.org/discord Discord]
* On IRC in #miraheze on irc.libera.chat ([irc://irc.libera.chat/%23miraheze direct link]; [https://web.libera.chat/?channel=#miraheze webchat])
=== For visitors of this wiki ===
Hello, the default Main Page of this wiki (this page) has not yet been replaced by the bureaucrat(s) of this wiki. The bureaucrat(s) might still be working on a Main Page, so please check again later!
21236ac3f8d65e5563b6da6b70815ca6bf1e6616
2
1
2023-10-01T07:12:21Z
Reverie
2
Replaced content with "[[REDIRECT:Home]]"
wikitext
text/x-wiki
[[REDIRECT:Home]]
f56700736749cbde367ec815f14db4d707964110
Main Page
0
1
3
2
2023-10-01T07:12:34Z
Reverie
2
wikitext
text/x-wiki
[[#REDIRECT:Home]]
b4aaea28b445edb434a3ed0bf0e287b2acf95b76
4
3
2023-10-01T07:13:57Z
Reverie
2
Redirected page to [[Home]]
wikitext
text/x-wiki
#REDIRECT [[Home]]
3c9846fc91826543c49e08653ad8ca1614c26b9e
Home
0
2
5
2023-10-01T07:27:42Z
Reverie
2
Created page with "<big>Welcome to Maritime Fiction!</big> =====What is this?===== Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company! Feel free to write anything here, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!"
wikitext
text/x-wiki
<big>Welcome to Maritime Fiction!</big>
=====What is this?=====
Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company!
Feel free to write anything here, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!
76ae4fa757d587340248551ad21819374d665946
6
5
2023-10-01T07:29:15Z
Reverie
2
/* What is this? */
wikitext
text/x-wiki
<big>Welcome to Maritime Fiction!</big>
=====What is this?=====
Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company!
=====What do I make here?=====
Feel free to write anything here, ships, captains, shipping lines, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!
94df15593557e80d7dfe2cd83096b2614c0f48ae
7
6
2023-10-01T07:56:52Z
Reverie
2
wikitext
text/x-wiki
<big>Welcome to Maritime Fiction!</big>
=====What is this?=====
Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company!
=====What do I make here?=====
Feel free to write anything here, ships, captains, shipping lines, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!
=== Start now! ===
[[Special:CreatePage|You can create an article/page by clicking here]]
9c007191f3f0ce22a9ad85e938a7eda334815b28
TSS ''Sarnia'' (1952)
0
4
10
2023-10-01T08:03:33Z
Reverie
2
Reverie moved page [[TSS ''Sarnia'' (1952)]] to [[TSS Sarnia (1952)]]
wikitext
text/x-wiki
#REDIRECT [[TSS Sarnia (1952)]]
35869289509d78299c0d0fb1d08abae840de039c
Template:Infobox
10
5
14
13
2023-10-01T08:20:56Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:Infobox|infobox}}<includeonly>{{template other|{{#ifeq:{{PAGENAME}}|Infobox||{{#ifeq:{{str left|{{SUBPAGENAME}}|7}}|Infobox|[[Category:Infobox templates|{{remove first word|{{SUBPAGENAME}}}}]]}}}}|}}</includeonly><noinclude>
{{documentation}}
<!-- Categories go in the /doc subpage, and interwikis go in Wikidata. -->
</noinclude>
817a9f5b6524eced06a57bd1d5fd7179f9369bf2
Module:Infobox
828
6
16
15
2023-10-01T08:20:56Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p = {}
local args = {}
local origArgs = {}
local root
local empty_row_categories = {}
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local has_rows = false
local lists = {
plainlist_t = {
patterns = {
'^plainlist$',
'%splainlist$',
'^plainlist%s',
'%splainlist%s'
},
found = false,
styles = 'Plainlist/styles.css'
},
hlist_t = {
patterns = {
'^hlist$',
'%shlist$',
'^hlist%s',
'%shlist%s'
},
found = false,
styles = 'Hlist/styles.css'
}
}
local function has_list_class(args_to_check)
for _, list in pairs(lists) do
if not list.found then
for _, arg in pairs(args_to_check) do
for _, pattern in ipairs(list.patterns) do
if mw.ustring.find(arg or '', pattern) then
list.found = true
break
end
end
if list.found then break end
end
end
end
end
local function fixChildBoxes(sval, tt)
local function notempty( s ) return s and s:match( '%S' ) end
if notempty(sval) then
local marker = '<span class=special_infobox_marker>'
local s = sval
-- start moving templatestyles and categories inside of table rows
local slast = ''
while slast ~= s do
slast = s
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*%]%])', '%2%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)', '%2%1')
end
-- end moving templatestyles and categories inside of table rows
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
if s:match(marker) then
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1')
end
if s:match(marker) then
local subcells = mw.text.split(s, marker)
s = ''
for k = 1, #subcells do
if k == 1 then
s = s .. subcells[k] .. '</' .. tt .. '></tr>'
elseif k == #subcells then
local rowstyle = ' style="display:none"'
if notempty(subcells[k]) then rowstyle = '' end
s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' ..
subcells[k]
elseif notempty(subcells[k]) then
if (k % 2) == 0 then
s = s .. subcells[k]
else
s = s .. '<tr><' .. tt .. ' colspan=2>\n' ..
subcells[k] .. '</' .. tt .. '></tr>'
end
end
end
end
-- the next two lines add a newline at the end of lists for the PHP parser
-- [[Special:Diff/849054481]]
-- remove when [[:phab:T191516]] is fixed or OBE
s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')
s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')
return s
else
return sval
end
end
-- Cleans empty tables
local function cleanInfobox()
root = tostring(root)
if has_rows == false then
root = mw.ustring.gsub(root, '<table[^<>]*>%s*</table>', '')
end
end
-- Returns the union of the values of two tables, as a sequence.
local function union(t1, t2)
local vals = {}
for k, v in pairs(t1) do
vals[v] = true
end
for k, v in pairs(t2) do
vals[v] = true
end
local ret = {}
for k, v in pairs(vals) do
table.insert(ret, k)
end
return ret
end
-- Returns a table containing the numbers of the arguments that exist
-- for the specified prefix. For example, if the prefix was 'data', and
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
local function getArgNums(prefix)
local nums = {}
for k, v in pairs(args) do
local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
if num then table.insert(nums, tonumber(num)) end
end
table.sort(nums)
return nums
end
-- Adds a row to the infobox, with either a header cell
-- or a label/data cell combination.
local function addRow(rowArgs)
if rowArgs.header and rowArgs.header ~= '_BLANK_' then
has_rows = true
has_list_class({ rowArgs.rowclass, rowArgs.class, args.headerclass })
root
:tag('tr')
:addClass(rowArgs.rowclass)
:cssText(rowArgs.rowstyle)
:tag('th')
:attr('colspan', '2')
:addClass('infobox-header')
:addClass(rowArgs.class)
:addClass(args.headerclass)
-- @deprecated next; target .infobox-<name> .infobox-header
:cssText(args.headerstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.header, 'th'))
if rowArgs.data then
root:wikitext(
'[[Category:Pages using infobox templates with ignored data cells]]'
)
end
elseif rowArgs.data and rowArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ rowArgs.rowclass, rowArgs.class })
local row = root:tag('tr')
row:addClass(rowArgs.rowclass)
row:cssText(rowArgs.rowstyle)
if rowArgs.label then
row
:tag('th')
:attr('scope', 'row')
:addClass('infobox-label')
-- @deprecated next; target .infobox-<name> .infobox-label
:cssText(args.labelstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(rowArgs.label)
:done()
end
local dataCell = row:tag('td')
dataCell
:attr('colspan', not rowArgs.label and '2' or nil)
:addClass(not rowArgs.label and 'infobox-full-data' or 'infobox-data')
:addClass(rowArgs.class)
-- @deprecated next; target .infobox-<name> .infobox(-full)-data
:cssText(rowArgs.datastyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.data, 'td'))
else
table.insert(empty_row_categories, rowArgs.data or '')
end
end
local function renderTitle()
if not args.title then return end
has_rows = true
has_list_class({args.titleclass})
root
:tag('caption')
:addClass('infobox-title')
:addClass(args.titleclass)
-- @deprecated next; target .infobox-<name> .infobox-title
:cssText(args.titlestyle)
:wikitext(args.title)
end
local function renderAboveRow()
if not args.above then return end
has_rows = true
has_list_class({ args.aboveclass })
root
:tag('tr')
:tag('th')
:attr('colspan', '2')
:addClass('infobox-above')
:addClass(args.aboveclass)
-- @deprecated next; target .infobox-<name> .infobox-above
:cssText(args.abovestyle)
:wikitext(fixChildBoxes(args.above,'th'))
end
local function renderBelowRow()
if not args.below then return end
has_rows = true
has_list_class({ args.belowclass })
root
:tag('tr')
:tag('td')
:attr('colspan', '2')
:addClass('infobox-below')
:addClass(args.belowclass)
-- @deprecated next; target .infobox-<name> .infobox-below
:cssText(args.belowstyle)
:wikitext(fixChildBoxes(args.below,'td'))
end
local function addSubheaderRow(subheaderArgs)
if subheaderArgs.data and
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ subheaderArgs.rowclass, subheaderArgs.class })
local row = root:tag('tr')
row:addClass(subheaderArgs.rowclass)
local dataCell = row:tag('td')
dataCell
:attr('colspan', '2')
:addClass('infobox-subheader')
:addClass(subheaderArgs.class)
:cssText(subheaderArgs.datastyle)
:cssText(subheaderArgs.rowcellstyle)
:wikitext(fixChildBoxes(subheaderArgs.data, 'td'))
else
table.insert(empty_row_categories, subheaderArgs.data or '')
end
end
local function renderSubheaders()
if args.subheader then
args.subheader1 = args.subheader
end
if args.subheaderrowclass then
args.subheaderrowclass1 = args.subheaderrowclass
end
local subheadernums = getArgNums('subheader')
for k, num in ipairs(subheadernums) do
addSubheaderRow({
data = args['subheader' .. tostring(num)],
-- @deprecated next; target .infobox-<name> .infobox-subheader
datastyle = args.subheaderstyle,
rowcellstyle = args['subheaderstyle' .. tostring(num)],
class = args.subheaderclass,
rowclass = args['subheaderrowclass' .. tostring(num)]
})
end
end
local function addImageRow(imageArgs)
if imageArgs.data and
imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ imageArgs.rowclass, imageArgs.class })
local row = root:tag('tr')
row:addClass(imageArgs.rowclass)
local dataCell = row:tag('td')
dataCell
:attr('colspan', '2')
:addClass('infobox-image')
:addClass(imageArgs.class)
:cssText(imageArgs.datastyle)
:wikitext(fixChildBoxes(imageArgs.data, 'td'))
else
table.insert(empty_row_categories, imageArgs.data or '')
end
end
local function renderImages()
if args.image then
args.image1 = args.image
end
if args.caption then
args.caption1 = args.caption
end
local imagenums = getArgNums('image')
for k, num in ipairs(imagenums) do
local caption = args['caption' .. tostring(num)]
local data = mw.html.create():wikitext(args['image' .. tostring(num)])
if caption then
data
:tag('div')
:addClass('infobox-caption')
-- @deprecated next; target .infobox-<name> .infobox-caption
:cssText(args.captionstyle)
:wikitext(caption)
end
addImageRow({
data = tostring(data),
-- @deprecated next; target .infobox-<name> .infobox-image
datastyle = args.imagestyle,
class = args.imageclass,
rowclass = args['imagerowclass' .. tostring(num)]
})
end
end
-- When autoheaders are turned on, preprocesses the rows
local function preprocessRows()
if not args.autoheaders then return end
local rownums = union(getArgNums('header'), getArgNums('data'))
table.sort(rownums)
local lastheader
for k, num in ipairs(rownums) do
if args['header' .. tostring(num)] then
if lastheader then
args['header' .. tostring(lastheader)] = nil
end
lastheader = num
elseif args['data' .. tostring(num)] and
args['data' .. tostring(num)]:gsub(
category_in_empty_row_pattern, ''
):match('^%S') then
local data = args['data' .. tostring(num)]
if data:gsub(category_in_empty_row_pattern, ''):match('%S') then
lastheader = nil
end
end
end
if lastheader then
args['header' .. tostring(lastheader)] = nil
end
end
-- Gets the union of the header and data argument numbers,
-- and renders them all in order
local function renderRows()
local rownums = union(getArgNums('header'), getArgNums('data'))
table.sort(rownums)
for k, num in ipairs(rownums) do
addRow({
header = args['header' .. tostring(num)],
label = args['label' .. tostring(num)],
data = args['data' .. tostring(num)],
datastyle = args.datastyle,
class = args['class' .. tostring(num)],
rowclass = args['rowclass' .. tostring(num)],
-- @deprecated next; target .infobox-<name> rowclass
rowstyle = args['rowstyle' .. tostring(num)],
rowcellstyle = args['rowcellstyle' .. tostring(num)]
})
end
end
local function renderNavBar()
if not args.name then return end
has_rows = true
root
:tag('tr')
:tag('td')
:attr('colspan', '2')
:addClass('infobox-navbar')
:wikitext(require('Module:Navbar')._navbar{
args.name,
mini = 1,
})
end
local function renderItalicTitle()
local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
root:wikitext(require('Module:Italic title')._main({}))
end
end
-- Categories in otherwise empty rows are collected in empty_row_categories.
-- This function adds them to the module output. It is not affected by
-- args.decat because this module should not prevent module-external categories
-- from rendering.
local function renderEmptyRowCategories()
for _, s in ipairs(empty_row_categories) do
root:wikitext(s)
end
end
-- Render tracking categories. args.decat == turns off tracking categories.
local function renderTrackingCategories()
if args.decat == 'yes' then return end
if args.child == 'yes' then
if args.title then
root:wikitext(
'[[Category:Pages using embedded infobox templates with the title parameter]]'
)
end
elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
root:wikitext('[[Category:Articles using infobox templates with no data rows]]')
end
end
--[=[
Loads the templatestyles for the infobox.
TODO: FINISH loading base templatestyles here rather than in
MediaWiki:Common.css. There are 4-5000 pages with 'raw' infobox tables.
See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :).
When we do this we should clean up the inline CSS below too.
Will have to do some bizarre conversion category like with sidebar.
]=]
local function loadTemplateStyles()
local frame = mw.getCurrentFrame()
local hlist_templatestyles = ''
if lists.hlist_t.found then
hlist_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = lists.hlist_t.styles }
}
end
local plainlist_templatestyles = ''
if lists.plainlist_t.found then
plainlist_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = lists.plainlist_t.styles }
}
end
-- See function description
local base_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Infobox/styles.css' }
}
local templatestyles = ''
if args['templatestyles'] then
templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['templatestyles'] }
}
end
local child_templatestyles = ''
if args['child templatestyles'] then
child_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['child templatestyles'] }
}
end
local grandchild_templatestyles = ''
if args['grandchild templatestyles'] then
grandchild_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
}
end
return table.concat({
-- hlist -> plainlist -> base is best-effort to preserve old Common.css ordering.
-- this ordering is not a guarantee because the rows of interest invoking
-- each class may not be on a specific page
hlist_templatestyles,
plainlist_templatestyles,
base_templatestyles,
templatestyles,
child_templatestyles,
grandchild_templatestyles
})
end
-- common functions between the child and non child cases
local function structure_infobox_common()
renderSubheaders()
renderImages()
preprocessRows()
renderRows()
renderBelowRow()
renderNavBar()
renderItalicTitle()
renderEmptyRowCategories()
renderTrackingCategories()
cleanInfobox()
end
-- Specify the overall layout of the infobox, with special settings if the
-- infobox is used as a 'child' inside another infobox.
local function _infobox()
if args.child ~= 'yes' then
root = mw.html.create('table')
root
:addClass(args.subbox == 'yes' and 'infobox-subbox' or 'infobox')
:addClass(args.bodyclass)
-- @deprecated next; target .infobox-<name>
:cssText(args.bodystyle)
has_list_class({ args.bodyclass })
renderTitle()
renderAboveRow()
else
root = mw.html.create()
root
:wikitext(args.title)
end
structure_infobox_common()
return loadTemplateStyles() .. root
end
-- If the argument exists and isn't blank, add it to the argument table.
-- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
local function preprocessSingleArg(argName)
if origArgs[argName] and origArgs[argName] ~= '' then
args[argName] = origArgs[argName]
end
end
-- Assign the parameters with the given prefixes to the args table, in order, in
-- batches of the step size specified. This is to prevent references etc. from
-- appearing in the wrong order. The prefixTable should be an array containing
-- tables, each of which has two possible fields, a "prefix" string and a
-- "depend" table. The function always parses parameters containing the "prefix"
-- string, but only parses parameters in the "depend" table if the prefix
-- parameter is present and non-blank.
local function preprocessArgs(prefixTable, step)
if type(prefixTable) ~= 'table' then
error("Non-table value detected for the prefix table", 2)
end
if type(step) ~= 'number' then
error("Invalid step value detected", 2)
end
-- Get arguments without a number suffix, and check for bad input.
for i,v in ipairs(prefixTable) do
if type(v) ~= 'table' or type(v.prefix) ~= "string" or
(v.depend and type(v.depend) ~= 'table') then
error('Invalid input detected to preprocessArgs prefix table', 2)
end
preprocessSingleArg(v.prefix)
-- Only parse the depend parameter if the prefix parameter is present
-- and not blank.
if args[v.prefix] and v.depend then
for j, dependValue in ipairs(v.depend) do
if type(dependValue) ~= 'string' then
error('Invalid "depend" parameter value detected in preprocessArgs')
end
preprocessSingleArg(dependValue)
end
end
end
-- Get arguments with number suffixes.
local a = 1 -- Counter variable.
local moreArgumentsExist = true
while moreArgumentsExist == true do
moreArgumentsExist = false
for i = a, a + step - 1 do
for j,v in ipairs(prefixTable) do
local prefixArgName = v.prefix .. tostring(i)
if origArgs[prefixArgName] then
-- Do another loop if any arguments are found, even blank ones.
moreArgumentsExist = true
preprocessSingleArg(prefixArgName)
end
-- Process the depend table if the prefix argument is present
-- and not blank, or we are processing "prefix1" and "prefix" is
-- present and not blank, and if the depend table is present.
if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then
for j,dependValue in ipairs(v.depend) do
local dependArgName = dependValue .. tostring(i)
preprocessSingleArg(dependArgName)
end
end
end
end
a = a + step
end
end
-- Parse the data parameters in the same order that the old {{infobox}} did, so
-- that references etc. will display in the expected places. Parameters that
-- depend on another parameter are only processed if that parameter is present,
-- to avoid phantom references appearing in article reference lists.
local function parseDataParameters()
preprocessSingleArg('autoheaders')
preprocessSingleArg('child')
preprocessSingleArg('bodyclass')
preprocessSingleArg('subbox')
preprocessSingleArg('bodystyle')
preprocessSingleArg('title')
preprocessSingleArg('titleclass')
preprocessSingleArg('titlestyle')
preprocessSingleArg('above')
preprocessSingleArg('aboveclass')
preprocessSingleArg('abovestyle')
preprocessArgs({
{prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}
}, 10)
preprocessSingleArg('subheaderstyle')
preprocessSingleArg('subheaderclass')
preprocessArgs({
{prefix = 'image', depend = {'caption', 'imagerowclass'}}
}, 10)
preprocessSingleArg('captionstyle')
preprocessSingleArg('imagestyle')
preprocessSingleArg('imageclass')
preprocessArgs({
{prefix = 'header'},
{prefix = 'data', depend = {'label'}},
{prefix = 'rowclass'},
{prefix = 'rowstyle'},
{prefix = 'rowcellstyle'},
{prefix = 'class'}
}, 50)
preprocessSingleArg('headerclass')
preprocessSingleArg('headerstyle')
preprocessSingleArg('labelstyle')
preprocessSingleArg('datastyle')
preprocessSingleArg('below')
preprocessSingleArg('belowclass')
preprocessSingleArg('belowstyle')
preprocessSingleArg('name')
-- different behaviour for italics if blank or absent
args['italic title'] = origArgs['italic title']
preprocessSingleArg('decat')
preprocessSingleArg('templatestyles')
preprocessSingleArg('child templatestyles')
preprocessSingleArg('grandchild templatestyles')
end
-- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
function p.infobox(frame)
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame
end
parseDataParameters()
return _infobox()
end
-- For calling via #invoke within a template
function p.infoboxTemplate(frame)
origArgs = {}
for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end
parseDataParameters()
return _infobox()
end
return p
0ddb7e5c8426d67cd589b710efb9912ddfb67fea
Module:Yesno
828
7
18
17
2023-10-01T08:20:56Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.
return function (val, default)
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
-- following line.
val = type(val) == 'string' and val:lower() or val
if val == nil then
return nil
elseif val == true
or val == 'yes'
or val == 'y'
or val == 'true'
or val == 't'
or val == 'on'
or tonumber(val) == 1
then
return true
elseif val == false
or val == 'no'
or val == 'n'
or val == 'false'
or val == 'f'
or val == 'off'
or tonumber(val) == 0
then
return false
else
return default
end
end
f767643e7d12126d020d88d662a3dd057817b9dc
Module:Arguments
828
8
20
19
2023-10-01T08:20:57Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module provides easy processing of arguments passed to Scribunto from
-- #invoke. It is intended for use by other Lua modules, and should not be
-- called from #invoke directly.
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local arguments = {}
-- Generate four different tidyVal functions, so that we don't have to check the
-- options every time we call it.
local function tidyValDefault(key, val)
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val == '' then
return nil
else
return val
end
else
return val
end
end
local function tidyValTrimOnly(key, val)
if type(val) == 'string' then
return val:match('^%s*(.-)%s*$')
else
return val
end
end
local function tidyValRemoveBlanksOnly(key, val)
if type(val) == 'string' then
if val:find('%S') then
return val
else
return nil
end
else
return val
end
end
local function tidyValNoChange(key, val)
return val
end
local function matchesTitle(given, title)
local tp = type( given )
return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end
local translate_mt = { __index = function(t, k) return k end }
function arguments.getArgs(frame, options)
checkType('getArgs', 1, frame, 'table', true)
checkType('getArgs', 2, options, 'table', true)
frame = frame or {}
options = options or {}
--[[
-- Set up argument translation.
--]]
options.translate = options.translate or {}
if getmetatable(options.translate) == nil then
setmetatable(options.translate, translate_mt)
end
if options.backtranslate == nil then
options.backtranslate = {}
for k,v in pairs(options.translate) do
options.backtranslate[v] = k
end
end
if options.backtranslate and getmetatable(options.backtranslate) == nil then
setmetatable(options.backtranslate, {
__index = function(t, k)
if options.translate[k] ~= k then
return nil
else
return k
end
end
})
end
--[[
-- Get the argument tables. If we were passed a valid frame object, get the
-- frame arguments (fargs) and the parent frame arguments (pargs), depending
-- on the options set and on the parent frame's availability. If we weren't
-- passed a valid frame object, we are being called from another Lua module
-- or from the debug console, so assume that we were passed a table of args
-- directly, and assign it to a new variable (luaArgs).
--]]
local fargs, pargs, luaArgs
if type(frame.args) == 'table' and type(frame.getParent) == 'function' then
if options.wrappers then
--[[
-- The wrappers option makes Module:Arguments look up arguments in
-- either the frame argument table or the parent argument table, but
-- not both. This means that users can use either the #invoke syntax
-- or a wrapper template without the loss of performance associated
-- with looking arguments up in both the frame and the parent frame.
-- Module:Arguments will look up arguments in the parent frame
-- if it finds the parent frame's title in options.wrapper;
-- otherwise it will look up arguments in the frame object passed
-- to getArgs.
--]]
local parent = frame:getParent()
if not parent then
fargs = frame.args
else
local title = parent:getTitle():gsub('/sandbox$', '')
local found = false
if matchesTitle(options.wrappers, title) then
found = true
elseif type(options.wrappers) == 'table' then
for _,v in pairs(options.wrappers) do
if matchesTitle(v, title) then
found = true
break
end
end
end
-- We test for false specifically here so that nil (the default) acts like true.
if found or options.frameOnly == false then
pargs = parent.args
end
if not found or options.parentOnly == false then
fargs = frame.args
end
end
else
-- options.wrapper isn't set, so check the other options.
if not options.parentOnly then
fargs = frame.args
end
if not options.frameOnly then
local parent = frame:getParent()
pargs = parent and parent.args or nil
end
end
if options.parentFirst then
fargs, pargs = pargs, fargs
end
else
luaArgs = frame
end
-- Set the order of precedence of the argument tables. If the variables are
-- nil, nothing will be added to the table, which is how we avoid clashes
-- between the frame/parent args and the Lua args.
local argTables = {fargs}
argTables[#argTables + 1] = pargs
argTables[#argTables + 1] = luaArgs
--[[
-- Generate the tidyVal function. If it has been specified by the user, we
-- use that; if not, we choose one of four functions depending on the
-- options chosen. This is so that we don't have to call the options table
-- every time the function is called.
--]]
local tidyVal = options.valueFunc
if tidyVal then
if type(tidyVal) ~= 'function' then
error(
"bad value assigned to option 'valueFunc'"
.. '(function expected, got '
.. type(tidyVal)
.. ')',
2
)
end
elseif options.trim ~= false then
if options.removeBlanks ~= false then
tidyVal = tidyValDefault
else
tidyVal = tidyValTrimOnly
end
else
if options.removeBlanks ~= false then
tidyVal = tidyValRemoveBlanksOnly
else
tidyVal = tidyValNoChange
end
end
--[[
-- Set up the args, metaArgs and nilArgs tables. args will be the one
-- accessed from functions, and metaArgs will hold the actual arguments. Nil
-- arguments are memoized in nilArgs, and the metatable connects all of them
-- together.
--]]
local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}
setmetatable(args, metatable)
local function mergeArgs(tables)
--[[
-- Accepts multiple tables as input and merges their keys and values
-- into one table. If a value is already present it is not overwritten;
-- tables listed earlier have precedence. We are also memoizing nil
-- values, which can be overwritten if they are 's' (soft).
--]]
for _, t in ipairs(tables) do
for key, val in pairs(t) do
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
local tidiedVal = tidyVal(key, val)
if tidiedVal == nil then
nilArgs[key] = 's'
else
metaArgs[key] = tidiedVal
end
end
end
end
end
--[[
-- Define metatable behaviour. Arguments are memoized in the metaArgs table,
-- and are only fetched from the argument tables once. Fetching arguments
-- from the argument tables is the most resource-intensive step in this
-- module, so we try and avoid it where possible. For this reason, nil
-- arguments are also memoized, in the nilArgs table. Also, we keep a record
-- in the metatable of when pairs and ipairs have been called, so we do not
-- run pairs and ipairs on the argument tables more than once. We also do
-- not run ipairs on fargs and pargs if pairs has already been run, as all
-- the arguments will already have been copied over.
--]]
metatable.__index = function (t, key)
--[[
-- Fetches an argument when the args table is indexed. First we check
-- to see if the value is memoized, and if not we try and fetch it from
-- the argument tables. When we check memoization, we need to check
-- metaArgs before nilArgs, as both can be non-nil at the same time.
-- If the argument is not present in metaArgs, we also check whether
-- pairs has been run yet. If pairs has already been run, we return nil.
-- This is because all the arguments will have already been copied into
-- metaArgs by the mergeArgs function, meaning that any other arguments
-- must be nil.
--]]
if type(key) == 'string' then
key = options.translate[key]
end
local val = metaArgs[key]
if val ~= nil then
return val
elseif metatable.donePairs or nilArgs[key] then
return nil
end
for _, argTable in ipairs(argTables) do
local argTableVal = tidyVal(key, argTable[key])
if argTableVal ~= nil then
metaArgs[key] = argTableVal
return argTableVal
end
end
nilArgs[key] = 'h'
return nil
end
metatable.__newindex = function (t, key, val)
-- This function is called when a module tries to add a new value to the
-- args table, or tries to change an existing value.
if type(key) == 'string' then
key = options.translate[key]
end
if options.readOnly then
error(
'could not write to argument table key "'
.. tostring(key)
.. '"; the table is read-only',
2
)
elseif options.noOverwrite and args[key] ~= nil then
error(
'could not write to argument table key "'
.. tostring(key)
.. '"; overwriting existing arguments is not permitted',
2
)
elseif val == nil then
--[[
-- If the argument is to be overwritten with nil, we need to erase
-- the value in metaArgs, so that __index, __pairs and __ipairs do
-- not use a previous existing value, if present; and we also need
-- to memoize the nil in nilArgs, so that the value isn't looked
-- up in the argument tables if it is accessed again.
--]]
metaArgs[key] = nil
nilArgs[key] = 'h'
else
metaArgs[key] = val
end
end
local function translatenext(invariant)
local k, v = next(invariant.t, invariant.k)
invariant.k = k
if k == nil then
return nil
elseif type(k) ~= 'string' or not options.backtranslate then
return k, v
else
local backtranslate = options.backtranslate[k]
if backtranslate == nil then
-- Skip this one. This is a tail call, so this won't cause stack overflow
return translatenext(invariant)
else
return backtranslate, v
end
end
end
metatable.__pairs = function ()
-- Called when pairs is run on the args table.
if not metatable.donePairs then
mergeArgs(argTables)
metatable.donePairs = true
end
return translatenext, { t = metaArgs }
end
local function inext(t, i)
-- This uses our __index metamethod
local v = t[i + 1]
if v ~= nil then
return i + 1, v
end
end
metatable.__ipairs = function (t)
-- Called when ipairs is run on the args table.
return inext, t, 0
end
return args
end
return arguments
3134ecce8429b810d445e29eae115e2ae4c36c53
Template:Tl
10
9
22
21
2023-10-01T08:20:57Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Template link]]
{{Redirect category shell|
{{R from move}}
}}
d6593bb3b4a866249f55d0f34b047a71fe1f1529
Template:Template link
10
10
24
23
2023-10-01T08:20:58Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{[[Template:{{{1}}}|{{{1}}}]]}}<noinclude>{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
eabbec62efe3044a98ebb3ce9e7d4d43c222351d
Module:Message box
828
11
26
25
2023-10-01T08:20:58Z
Reverie
2
1 revision imported
Scribunto
text/plain
require('strict')
local getArgs
local yesno = require('Module:Yesno')
local lang = mw.language.getContentLanguage()
local CONFIG_MODULE = 'Module:Message box/configuration'
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function getTitleObject(...)
-- Get the title object, passing the function through pcall
-- in case we are over the expensive function count limit.
local success, title = pcall(mw.title.new, ...)
if success then
return title
end
end
local function union(t1, t2)
-- Returns the union of two arrays.
local vals = {}
for i, v in ipairs(t1) do
vals[v] = true
end
for i, v in ipairs(t2) do
vals[v] = true
end
local ret = {}
for k in pairs(vals) do
table.insert(ret, k)
end
table.sort(ret)
return ret
end
local function getArgNums(args, prefix)
local nums = {}
for k, v in pairs(args) do
local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')
if num then
table.insert(nums, tonumber(num))
end
end
table.sort(nums)
return nums
end
--------------------------------------------------------------------------------
-- Box class definition
--------------------------------------------------------------------------------
local MessageBox = {}
MessageBox.__index = MessageBox
function MessageBox.new(boxType, args, cfg)
args = args or {}
local obj = {}
-- Set the title object and the namespace.
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()
-- Set the config for our box type.
obj.cfg = cfg[boxType]
if not obj.cfg then
local ns = obj.title.namespace
-- boxType is "mbox" or invalid input
if args.demospace and args.demospace ~= '' then
-- implement demospace parameter of mbox
local demospace = string.lower(args.demospace)
if DEMOSPACES[demospace] then
-- use template from DEMOSPACES
obj.cfg = cfg[DEMOSPACES[demospace]]
elseif string.find( demospace, 'talk' ) then
-- demo as a talk page
obj.cfg = cfg.tmbox
else
-- default to ombox
obj.cfg = cfg.ombox
end
elseif ns == 0 then
obj.cfg = cfg.ambox -- main namespace
elseif ns == 6 then
obj.cfg = cfg.imbox -- file namespace
elseif ns == 14 then
obj.cfg = cfg.cmbox -- category namespace
else
local nsTable = mw.site.namespaces[ns]
if nsTable and nsTable.isTalk then
obj.cfg = cfg.tmbox -- any talk namespace
else
obj.cfg = cfg.ombox -- other namespaces or invalid input
end
end
end
-- Set the arguments, and remove all blank arguments except for the ones
-- listed in cfg.allowBlankParams.
do
local newArgs = {}
for k, v in pairs(args) do
if v ~= '' then
newArgs[k] = v
end
end
for i, param in ipairs(obj.cfg.allowBlankParams or {}) do
newArgs[param] = args[param]
end
obj.args = newArgs
end
-- Define internal data structure.
obj.categories = {}
obj.classes = {}
-- For lazy loading of [[Module:Category handler]].
obj.hasCategories = false
return setmetatable(obj, MessageBox)
end
function MessageBox:addCat(ns, cat, sort)
if not cat then
return nil
end
if sort then
cat = string.format('[[Category:%s|%s]]', cat, sort)
else
cat = string.format('[[Category:%s]]', cat)
end
self.hasCategories = true
self.categories[ns] = self.categories[ns] or {}
table.insert(self.categories[ns], cat)
end
function MessageBox:addClass(class)
if not class then
return nil
end
table.insert(self.classes, class)
end
function MessageBox:setParameters()
local args = self.args
local cfg = self.cfg
-- Get type data.
self.type = args.type
local typeData = cfg.types[self.type]
self.invalidTypeError = cfg.showInvalidTypeError
and self.type
and not typeData
typeData = typeData or cfg.types[cfg.default]
self.typeClass = typeData.class
self.typeImage = typeData.image
self.typeImageNeedsLink = typeData.imageNeedsLink
-- Find if the box has been wrongly substituted.
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'
-- Find whether we are using a small message box.
self.isSmall = cfg.allowSmall and (
cfg.smallParam and args.small == cfg.smallParam
or not cfg.smallParam and yesno(args.small)
)
-- Add attributes, classes and styles.
self.id = args.id
self.name = args.name
if self.name then
self:addClass('box-' .. string.gsub(self.name,' ','_'))
end
if yesno(args.plainlinks) ~= false then
self:addClass('plainlinks')
end
for _, class in ipairs(cfg.classes or {}) do
self:addClass(class)
end
if self.isSmall then
self:addClass(cfg.smallClass or 'mbox-small')
end
self:addClass(self.typeClass)
self:addClass(args.class)
self.style = args.style
self.attrs = args.attrs
-- Set text style.
self.textstyle = args.textstyle
-- Find if we are on the template page or not. This functionality is only
-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
-- and cfg.templateCategoryRequireName are set.
self.useCollapsibleTextFields = cfg.useCollapsibleTextFields
if self.useCollapsibleTextFields
or cfg.templateCategory
and cfg.templateCategoryRequireName
then
if self.name then
local templateName = mw.ustring.match(
self.name,
'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
) or self.name
templateName = 'Template:' .. templateName
self.templateTitle = getTitleObject(templateName)
end
self.isTemplatePage = self.templateTitle
and mw.title.equals(self.title, self.templateTitle)
end
-- Process data for collapsible text fields. At the moment these are only
-- used in {{ambox}}.
if self.useCollapsibleTextFields then
-- Get the self.issue value.
if self.isSmall and args.smalltext then
self.issue = args.smalltext
else
local sect
if args.sect == '' then
sect = 'This ' .. (cfg.sectionDefault or 'page')
elseif type(args.sect) == 'string' then
sect = 'This ' .. args.sect
end
local issue = args.issue
issue = type(issue) == 'string' and issue ~= '' and issue or nil
local text = args.text
text = type(text) == 'string' and text or nil
local issues = {}
table.insert(issues, sect)
table.insert(issues, issue)
table.insert(issues, text)
self.issue = table.concat(issues, ' ')
end
-- Get the self.talk value.
local talk = args.talk
-- Show talk links on the template page or template subpages if the talk
-- parameter is blank.
if talk == ''
and self.templateTitle
and (
mw.title.equals(self.templateTitle, self.title)
or self.title:isSubpageOf(self.templateTitle)
)
then
talk = '#'
elseif talk == '' then
talk = nil
end
if talk then
-- If the talk value is a talk page, make a link to that page. Else
-- assume that it's a section heading, and make a link to the talk
-- page of the current page with that section heading.
local talkTitle = getTitleObject(talk)
local talkArgIsTalkPage = true
if not talkTitle or not talkTitle.isTalkPage then
talkArgIsTalkPage = false
talkTitle = getTitleObject(
self.title.text,
mw.site.namespaces[self.title.namespace].talk.id
)
end
if talkTitle and talkTitle.exists then
local talkText
if self.isSmall then
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)
talkText = string.format('([[%s|talk]])', talkLink)
else
talkText = 'Relevant discussion may be found on'
if talkArgIsTalkPage then
talkText = string.format(
'%s [[%s|%s]].',
talkText,
talk,
talkTitle.prefixedText
)
else
talkText = string.format(
'%s the [[%s#%s|talk page]].',
talkText,
talkTitle.prefixedText,
talk
)
end
end
self.talk = talkText
end
end
-- Get other values.
self.fix = args.fix ~= '' and args.fix or nil
local date
if args.date and args.date ~= '' then
date = args.date
elseif args.date == '' and self.isTemplatePage then
date = lang:formatDate('F Y')
end
if date then
self.date = string.format(" <span class='date-container'><i>(<span class='date'>%s</span>)</i></span>", date)
end
self.info = args.info
if yesno(args.removalnotice) then
self.removalNotice = cfg.removalNotice
end
end
-- Set the non-collapsible text field. At the moment this is used by all box
-- types other than ambox, and also by ambox when small=yes.
if self.isSmall then
self.text = args.smalltext or args.text
else
self.text = args.text
end
-- Set the below row.
self.below = cfg.below and args.below
-- General image settings.
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
self.imageEmptyCell = cfg.imageEmptyCell
-- Left image settings.
local imageLeft = self.isSmall and args.smallimage or args.image
if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
or not cfg.imageCheckBlank and imageLeft ~= 'none'
then
self.imageLeft = imageLeft
if not imageLeft then
local imageSize = self.isSmall
and (cfg.imageSmallSize or '30x30px')
or '40x40px'
self.imageLeft = string.format('[[File:%s|%s%s|alt=]]', self.typeImage
or 'Information icon4.svg', imageSize, self.typeImageNeedsLink and "" or "|link=" )
end
end
-- Right image settings.
local imageRight = self.isSmall and args.smallimageright or args.imageright
if not (cfg.imageRightNone and imageRight == 'none') then
self.imageRight = imageRight
end
-- set templatestyles
self.base_templatestyles = cfg.templatestyles
self.templatestyles = args.templatestyles
end
function MessageBox:setMainspaceCategories()
local args = self.args
local cfg = self.cfg
if not cfg.allowMainspaceCategories then
return nil
end
local nums = {}
for _, prefix in ipairs{'cat', 'category', 'all'} do
args[prefix .. '1'] = args[prefix]
nums = union(nums, getArgNums(args, prefix))
end
-- The following is roughly equivalent to the old {{Ambox/category}}.
local date = args.date
date = type(date) == 'string' and date
local preposition = 'from'
for _, num in ipairs(nums) do
local mainCat = args['cat' .. tostring(num)]
or args['category' .. tostring(num)]
local allCat = args['all' .. tostring(num)]
mainCat = type(mainCat) == 'string' and mainCat
allCat = type(allCat) == 'string' and allCat
if mainCat and date and date ~= '' then
local catTitle = string.format('%s %s %s', mainCat, preposition, date)
self:addCat(0, catTitle)
catTitle = getTitleObject('Category:' .. catTitle)
if not catTitle or not catTitle.exists then
self:addCat(0, 'Articles with invalid date parameter in template')
end
elseif mainCat and (not date or date == '') then
self:addCat(0, mainCat)
end
if allCat then
self:addCat(0, allCat)
end
end
end
function MessageBox:setTemplateCategories()
local args = self.args
local cfg = self.cfg
-- Add template categories.
if cfg.templateCategory then
if cfg.templateCategoryRequireName then
if self.isTemplatePage then
self:addCat(10, cfg.templateCategory)
end
elseif not self.title.isSubpage then
self:addCat(10, cfg.templateCategory)
end
end
-- Add template error categories.
if cfg.templateErrorCategory then
local templateErrorCategory = cfg.templateErrorCategory
local templateCat, templateSort
if not self.name and not self.title.isSubpage then
templateCat = templateErrorCategory
elseif self.isTemplatePage then
local paramsToCheck = cfg.templateErrorParamsToCheck or {}
local count = 0
for i, param in ipairs(paramsToCheck) do
if not args[param] then
count = count + 1
end
end
if count > 0 then
templateCat = templateErrorCategory
templateSort = tostring(count)
end
if self.categoryNums and #self.categoryNums > 0 then
templateCat = templateErrorCategory
templateSort = 'C'
end
end
self:addCat(10, templateCat, templateSort)
end
end
function MessageBox:setAllNamespaceCategories()
-- Set categories for all namespaces.
if self.invalidTypeError then
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
end
if self.isSubstituted then
self:addCat('all', 'Pages with incorrectly substituted templates')
end
end
function MessageBox:setCategories()
if self.title.namespace == 0 then
self:setMainspaceCategories()
elseif self.title.namespace == 10 then
self:setTemplateCategories()
end
self:setAllNamespaceCategories()
end
function MessageBox:renderCategories()
if not self.hasCategories then
-- No categories added, no need to pass them to Category handler so,
-- if it was invoked, it would return the empty string.
-- So we shortcut and return the empty string.
return ""
end
-- Convert category tables to strings and pass them through
-- [[Module:Category handler]].
return require('Module:Category handler')._main{
main = table.concat(self.categories[0] or {}),
template = table.concat(self.categories[10] or {}),
all = table.concat(self.categories.all or {}),
nocat = self.args.nocat,
page = self.args.page
}
end
function MessageBox:export()
local root = mw.html.create()
-- Add the subst check error.
if self.isSubstituted and self.name then
root:tag('b')
:addClass('error')
:wikitext(string.format(
'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
))
end
local frame = mw.getCurrentFrame()
root:wikitext(frame:extensionTag{
name = 'templatestyles',
args = { src = self.base_templatestyles },
})
-- Add support for a single custom templatestyles sheet. Undocumented as
-- need should be limited and many templates using mbox are substed; we
-- don't want to spread templatestyles sheets around to arbitrary places
if self.templatestyles then
root:wikitext(frame:extensionTag{
name = 'templatestyles',
args = { src = self.templatestyles },
})
end
-- Create the box table.
local boxTable = root:tag('table')
boxTable:attr('id', self.id or nil)
for i, class in ipairs(self.classes or {}) do
boxTable:addClass(class or nil)
end
boxTable
:cssText(self.style or nil)
:attr('role', 'presentation')
if self.attrs then
boxTable:attr(self.attrs)
end
-- Add the left-hand image.
local row = boxTable:tag('tr')
if self.imageLeft then
local imageLeftCell = row:tag('td'):addClass('mbox-image')
if self.imageCellDiv then
-- If we are using a div, redefine imageLeftCell so that the image
-- is inside it. Divs use style="width: 52px;", which limits the
-- image width to 52px. If any images in a div are wider than that,
-- they may overlap with the text or cause other display problems.
imageLeftCell = imageLeftCell:tag('div'):addClass('mbox-image-div')
end
imageLeftCell:wikitext(self.imageLeft or nil)
elseif self.imageEmptyCell then
-- Some message boxes define an empty cell if no image is specified, and
-- some don't. The old template code in templates where empty cells are
-- specified gives the following hint: "No image. Cell with some width
-- or padding necessary for text cell to have 100% width."
row:tag('td')
:addClass('mbox-empty-cell')
end
-- Add the text.
local textCell = row:tag('td'):addClass('mbox-text')
if self.useCollapsibleTextFields then
-- The message box uses advanced text parameters that allow things to be
-- collapsible. At the moment, only ambox uses this.
textCell:cssText(self.textstyle or nil)
local textCellDiv = textCell:tag('div')
textCellDiv
:addClass('mbox-text-span')
:wikitext(self.issue or nil)
if (self.talk or self.fix) then
textCellDiv:tag('span')
:addClass('hide-when-compact')
:wikitext(self.talk and (' ' .. self.talk) or nil)
:wikitext(self.fix and (' ' .. self.fix) or nil)
end
textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)
if self.info and not self.isSmall then
textCellDiv
:tag('span')
:addClass('hide-when-compact')
:wikitext(self.info and (' ' .. self.info) or nil)
end
if self.removalNotice then
textCellDiv:tag('span')
:addClass('hide-when-compact')
:tag('i')
:wikitext(string.format(" (%s)", self.removalNotice))
end
else
-- Default text formatting - anything goes.
textCell
:cssText(self.textstyle or nil)
:wikitext(self.text or nil)
end
-- Add the right-hand image.
if self.imageRight then
local imageRightCell = row:tag('td'):addClass('mbox-imageright')
if self.imageCellDiv then
-- If we are using a div, redefine imageRightCell so that the image
-- is inside it.
imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div')
end
imageRightCell
:wikitext(self.imageRight or nil)
end
-- Add the below row.
if self.below then
boxTable:tag('tr')
:tag('td')
:attr('colspan', self.imageRight and '3' or '2')
:addClass('mbox-text')
:cssText(self.textstyle or nil)
:wikitext(self.below or nil)
end
-- Add error message for invalid type parameters.
if self.invalidTypeError then
root:tag('div')
:addClass('mbox-invalid-type')
:wikitext(string.format(
'This message box is using an invalid "type=%s" parameter and needs fixing.',
self.type or ''
))
end
-- Add categories.
root:wikitext(self:renderCategories() or nil)
return tostring(root)
end
--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------
local p, mt = {}, {}
function p._exportClasses()
-- For testing.
return {
MessageBox = MessageBox
}
end
function p.main(boxType, args, cfgTables)
local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))
box:setParameters()
box:setCategories()
return box:export()
end
function mt.__index(t, k)
return function (frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
end
end
return setmetatable(p, mt)
f2fb84f7b817d2d88747f57c40902a0d8be8158a
Module:Message box/configuration
828
12
28
27
2023-10-01T08:20:59Z
Reverie
2
1 revision imported
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Message box configuration --
-- --
-- This module contains configuration data for [[Module:Message box]]. --
--------------------------------------------------------------------------------
return {
ambox = {
types = {
speedy = {
class = 'ambox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'ambox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'ambox-content',
image = 'Ambox important.svg'
},
style = {
class = 'ambox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'ambox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'ambox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'ambox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},
allowSmall = true,
smallParam = 'left',
smallClass = 'mbox-small-left',
substCheck = true,
classes = {'metadata', 'ambox'},
imageEmptyCell = true,
imageCheckBlank = true,
imageSmallSize = '20x20px',
imageCellDiv = true,
useCollapsibleTextFields = true,
imageRightNone = true,
sectionDefault = 'article',
allowMainspaceCategories = true,
templateCategory = 'Article message templates',
templateCategoryRequireName = true,
templateErrorCategory = 'Article message templates with missing parameters',
templateErrorParamsToCheck = {'issue', 'fix', 'subst'},
removalNotice = '<small>[[Help:Maintenance template removal|Learn how and when to remove this template message]]</small>',
templatestyles = 'Module:Message box/ambox.css'
},
cmbox = {
types = {
speedy = {
class = 'cmbox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'cmbox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'cmbox-content',
image = 'Ambox important.svg'
},
style = {
class = 'cmbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'cmbox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'cmbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'cmbox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
showInvalidTypeError = true,
classes = {'cmbox'},
imageEmptyCell = true,
templatestyles = 'Module:Message box/cmbox.css'
},
fmbox = {
types = {
warning = {
class = 'fmbox-warning',
image = 'Ambox warning pn.svg'
},
editnotice = {
class = 'fmbox-editnotice',
image = 'Information icon4.svg'
},
system = {
class = 'fmbox-system',
image = 'Information icon4.svg'
}
},
default = 'system',
showInvalidTypeError = true,
classes = {'fmbox'},
imageEmptyCell = false,
imageRightNone = false,
templatestyles = 'Module:Message box/fmbox.css'
},
imbox = {
types = {
speedy = {
class = 'imbox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'imbox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'imbox-content',
image = 'Ambox important.svg'
},
style = {
class = 'imbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'imbox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'imbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
license = {
class = 'imbox-license licensetpl',
image = 'Imbox-license.svg'
},
featured = {
class = 'imbox-featured',
image = 'Cscr-featured.svg',
imageNeedsLink = true
},
notice = {
class = 'imbox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
showInvalidTypeError = true,
classes = {'imbox'},
imageEmptyCell = true,
below = true,
templateCategory = 'File message boxes',
templatestyles = 'Module:Message box/imbox.css'
},
ombox = {
types = {
speedy = {
class = 'ombox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'ombox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'ombox-content',
image = 'Ambox important.svg'
},
style = {
class = 'ombox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'ombox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'ombox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'ombox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
showInvalidTypeError = true,
classes = {'ombox'},
allowSmall = true,
imageEmptyCell = true,
imageRightNone = true,
templatestyles = 'Module:Message box/ombox.css'
},
tmbox = {
types = {
speedy = {
class = 'tmbox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'tmbox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'tmbox-content',
image = 'Ambox important.svg'
},
style = {
class = 'tmbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'tmbox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'tmbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'tmbox-notice',
image = 'Information icon4.svg'
}
},
default = 'notice',
showInvalidTypeError = true,
classes = {'tmbox'},
allowSmall = true,
imageRightNone = true,
imageEmptyCell = true,
templateCategory = 'Talk message boxes',
templatestyles = 'Module:Message box/tmbox.css'
}
}
27f00af5cf3939613e9156acd5e62a3469d03d81
Template:Yesno
10
13
30
29
2023-10-01T08:20:59Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{<includeonly>safesubst:</includeonly>#switch: {{<includeonly>safesubst:</includeonly>lc: {{{1|¬}}} }}
|no
|n
|f
|false
|off
|0 = {{{no|<!-- null -->}}}
| = {{{blank|{{{no|<!-- null -->}}}}}}
|¬ = {{{¬|}}}
|yes
|y
|t
|true
|on
|1 = {{{yes|yes}}}
|#default = {{{def|{{{yes|yes}}}}}}
}}<noinclude>
{{Documentation}}
</noinclude>
629c2937bc5cf7cfe13cd2a598582af832782399
Template:Main other
10
14
32
31
2023-10-01T08:21:00Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#switch:
<!--If no or empty "demospace" parameter then detect namespace-->
{{#if:{{{demospace|}}}
| {{lc: {{{demospace}}} }} <!--Use lower case "demospace"-->
| {{#ifeq:{{NAMESPACE}}|{{ns:0}}
| main
| other
}}
}}
| main = {{{1|}}}
| other
| #default = {{{2|}}}
}}<noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! -->
</noinclude>
86ad907ffeea3cc545159e00cd1f2d6433946450
Template:Nobold
10
15
34
33
2023-10-01T08:21:00Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<templatestyles src="Nobold/styles.css"/><span class="nobold">{{{1}}}</span><noinclude>
{{documentation}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS -->
</noinclude>
9c92b5951772bb26ca0fbe9256418b65e47700dd
Template:Nobold/styles.css
10
16
36
35
2023-10-01T08:21:01Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp-template}} */
/* Styling for Template:Nobold */
.nobold {
font-weight: normal;
}
83e5f0adacf8c7984251f1fd9d11ed82ebaadf03
Module:Check for unknown parameters
828
17
38
37
2023-10-01T08:21:02Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module may be used to compare the arguments passed to the parent
-- with a list of arguments, returning a specified result if an argument is
-- not on the list
local p = {}
local function trim(s)
return s:match('^%s*(.-)%s*$')
end
local function isnotempty(s)
return s and s:match('%S')
end
local function clean(text)
-- Return text cleaned for display and truncated if too long.
-- Strip markers are replaced with dummy text representing the original wikitext.
local pos, truncated
local function truncate(text)
if truncated then
return ''
end
if mw.ustring.len(text) > 25 then
truncated = true
text = mw.ustring.sub(text, 1, 25) .. '...'
end
return mw.text.nowiki(text)
end
local parts = {}
for before, tag, remainder in text:gmatch('([^\127]*)\127[^\127]*%-(%l+)%-[^\127]*\127()') do
pos = remainder
table.insert(parts, truncate(before) .. '<' .. tag .. '>...</' .. tag .. '>')
end
table.insert(parts, truncate(text:sub(pos or 1)))
return table.concat(parts)
end
function p._check(args, pargs)
if type(args) ~= "table" or type(pargs) ~= "table" then
-- TODO: error handling
return
end
-- create the list of known args, regular expressions, and the return string
local knownargs = {}
local regexps = {}
for k, v in pairs(args) do
if type(k) == 'number' then
v = trim(v)
knownargs[v] = 1
elseif k:find('^regexp[1-9][0-9]*$') then
table.insert(regexps, '^' .. v .. '$')
end
end
-- loop over the parent args, and make sure they are on the list
local ignoreblank = isnotempty(args['ignoreblank'])
local showblankpos = isnotempty(args['showblankpositional'])
local values = {}
for k, v in pairs(pargs) do
if type(k) == 'string' and knownargs[k] == nil then
local knownflag = false
for _, regexp in ipairs(regexps) do
if mw.ustring.match(k, regexp) then
knownflag = true
break
end
end
if not knownflag and ( not ignoreblank or isnotempty(v) ) then
table.insert(values, clean(k))
end
elseif type(k) == 'number' and knownargs[tostring(k)] == nil then
local knownflag = false
for _, regexp in ipairs(regexps) do
if mw.ustring.match(tostring(k), regexp) then
knownflag = true
break
end
end
if not knownflag and ( showblankpos or isnotempty(v) ) then
table.insert(values, k .. ' = ' .. clean(v))
end
end
end
-- add results to the output tables
local res = {}
if #values > 0 then
local unknown_text = args['unknown'] or 'Found _VALUE_, '
if mw.getCurrentFrame():preprocess( "{{REVISIONID}}" ) == "" then
local preview_text = args['preview']
if isnotempty(preview_text) then
preview_text = require('Module:If preview')._warning({preview_text})
elseif preview == nil then
preview_text = unknown_text
end
unknown_text = preview_text
end
for _, v in pairs(values) do
-- Fix odd bug for | = which gets stripped to the empty string and
-- breaks category links
if v == '' then v = ' ' end
-- avoid error with v = 'example%2' ("invalid capture index")
local r = unknown_text:gsub('_VALUE_', {_VALUE_ = v})
table.insert(res, r)
end
end
return table.concat(res)
end
function p.check(frame)
local args = frame.args
local pargs = frame:getParent().args
return p._check(args, pargs)
end
return p
93db6d115d4328d2a5148bb42959105e367b663e
Module:String
828
18
40
39
2023-10-01T08:21:03Z
Reverie
2
1 revision imported
Scribunto
text/plain
--[[
This module is intended to provide access to basic string functions.
Most of the functions provided here can be invoked with named parameters,
unnamed parameters, or a mixture. If named parameters are used, Mediawiki will
automatically remove any leading or trailing whitespace from the parameter.
Depending on the intended use, it may be advantageous to either preserve or
remove such whitespace.
Global options
ignore_errors: If set to 'true' or 1, any error condition will result in
an empty string being returned rather than an error message.
error_category: If an error occurs, specifies the name of a category to
include with the error message. The default category is
[Category:Errors reported by Module String].
no_category: If set to 'true' or 1, no category will be added if an error
is generated.
Unit tests for this module are available at Module:String/tests.
]]
local str = {}
--[[
len
This function returns the length of the target string.
Usage:
{{#invoke:String|len|target_string|}}
OR
{{#invoke:String|len|s=target_string}}
Parameters
s: The string whose length to report
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from the target string.
]]
function str.len( frame )
local new_args = str._getParameters( frame.args, {'s'} )
local s = new_args['s'] or ''
return mw.ustring.len( s )
end
--[[
sub
This function returns a substring of the target string at specified indices.
Usage:
{{#invoke:String|sub|target_string|start_index|end_index}}
OR
{{#invoke:String|sub|s=target_string|i=start_index|j=end_index}}
Parameters
s: The string to return a subset of
i: The fist index of the substring to return, defaults to 1.
j: The last index of the string to return, defaults to the last character.
The first character of the string is assigned an index of 1. If either i or j
is a negative value, it is interpreted the same as selecting a character by
counting from the end of the string. Hence, a value of -1 is the same as
selecting the last character of the string.
If the requested indices are out of range for the given string, an error is
reported.
]]
function str.sub( frame )
local new_args = str._getParameters( frame.args, { 's', 'i', 'j' } )
local s = new_args['s'] or ''
local i = tonumber( new_args['i'] ) or 1
local j = tonumber( new_args['j'] ) or -1
local len = mw.ustring.len( s )
-- Convert negatives for range checking
if i < 0 then
i = len + i + 1
end
if j < 0 then
j = len + j + 1
end
if i > len or j > len or i < 1 or j < 1 then
return str._error( 'String subset index out of range' )
end
if j < i then
return str._error( 'String subset indices out of order' )
end
return mw.ustring.sub( s, i, j )
end
--[[
This function implements that features of {{str sub old}} and is kept in order
to maintain these older templates.
]]
function str.sublength( frame )
local i = tonumber( frame.args.i ) or 0
local len = tonumber( frame.args.len )
return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) )
end
--[[
_match
This function returns a substring from the source string that matches a
specified pattern. It is exported for use in other modules
Usage:
strmatch = require("Module:String")._match
sresult = strmatch( s, pattern, start, match, plain, nomatch )
Parameters
s: The string to search
pattern: The pattern or string to find within the string
start: The index within the source string to start the search. The first
character of the string has index 1. Defaults to 1.
match: In some cases it may be possible to make multiple matches on a single
string. This specifies which match to return, where the first match is
match= 1. If a negative number is specified then a match is returned
counting from the last match. Hence match = -1 is the same as requesting
the last match. Defaults to 1.
plain: A flag indicating that the pattern should be understood as plain
text. Defaults to false.
nomatch: If no match is found, output the "nomatch" value rather than an error.
For information on constructing Lua patterns, a form of [regular expression], see:
* http://www.lua.org/manual/5.1/manual.html#5.4.1
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns
]]
-- This sub-routine is exported for use in other modules
function str._match( s, pattern, start, match_index, plain_flag, nomatch )
if s == '' then
return str._error( 'Target string is empty' )
end
if pattern == '' then
return str._error( 'Pattern string is empty' )
end
start = tonumber(start) or 1
if math.abs(start) < 1 or math.abs(start) > mw.ustring.len( s ) then
return str._error( 'Requested start is out of range' )
end
if match_index == 0 then
return str._error( 'Match index is out of range' )
end
if plain_flag then
pattern = str._escapePattern( pattern )
end
local result
if match_index == 1 then
-- Find first match is simple case
result = mw.ustring.match( s, pattern, start )
else
if start > 1 then
s = mw.ustring.sub( s, start )
end
local iterator = mw.ustring.gmatch(s, pattern)
if match_index > 0 then
-- Forward search
for w in iterator do
match_index = match_index - 1
if match_index == 0 then
result = w
break
end
end
else
-- Reverse search
local result_table = {}
local count = 1
for w in iterator do
result_table[count] = w
count = count + 1
end
result = result_table[ count + match_index ]
end
end
if result == nil then
if nomatch == nil then
return str._error( 'Match not found' )
else
return nomatch
end
else
return result
end
end
--[[
match
This function returns a substring from the source string that matches a
specified pattern.
Usage:
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}
OR
{{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index
|match=match_number|plain=plain_flag|nomatch=nomatch_output}}
Parameters
s: The string to search
pattern: The pattern or string to find within the string
start: The index within the source string to start the search. The first
character of the string has index 1. Defaults to 1.
match: In some cases it may be possible to make multiple matches on a single
string. This specifies which match to return, where the first match is
match= 1. If a negative number is specified then a match is returned
counting from the last match. Hence match = -1 is the same as requesting
the last match. Defaults to 1.
plain: A flag indicating that the pattern should be understood as plain
text. Defaults to false.
nomatch: If no match is found, output the "nomatch" value rather than an error.
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from each string. In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
If the match_number or start_index are out of range for the string being queried, then
this function generates an error. An error is also generated if no match is found.
If one adds the parameter ignore_errors=true, then the error will be suppressed and
an empty string will be returned on any failure.
For information on constructing Lua patterns, a form of [regular expression], see:
* http://www.lua.org/manual/5.1/manual.html#5.4.1
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns
]]
-- This is the entry point for #invoke:String|match
function str.match( frame )
local new_args = str._getParameters( frame.args, {'s', 'pattern', 'start', 'match', 'plain', 'nomatch'} )
local s = new_args['s'] or ''
local start = tonumber( new_args['start'] ) or 1
local plain_flag = str._getBoolean( new_args['plain'] or false )
local pattern = new_args['pattern'] or ''
local match_index = math.floor( tonumber(new_args['match']) or 1 )
local nomatch = new_args['nomatch']
return str._match( s, pattern, start, match_index, plain_flag, nomatch )
end
--[[
pos
This function returns a single character from the target string at position pos.
Usage:
{{#invoke:String|pos|target_string|index_value}}
OR
{{#invoke:String|pos|target=target_string|pos=index_value}}
Parameters
target: The string to search
pos: The index for the character to return
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from the target string. In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
The first character has an index value of 1.
If one requests a negative value, this function will select a character by counting backwards
from the end of the string. In other words pos = -1 is the same as asking for the last character.
A requested value of zero, or a value greater than the length of the string returns an error.
]]
function str.pos( frame )
local new_args = str._getParameters( frame.args, {'target', 'pos'} )
local target_str = new_args['target'] or ''
local pos = tonumber( new_args['pos'] ) or 0
if pos == 0 or math.abs(pos) > mw.ustring.len( target_str ) then
return str._error( 'String index out of range' )
end
return mw.ustring.sub( target_str, pos, pos )
end
--[[
str_find
This function duplicates the behavior of {{str_find}}, including all of its quirks.
This is provided in order to support existing templates, but is NOT RECOMMENDED for
new code and templates. New code is recommended to use the "find" function instead.
Returns the first index in "source" that is a match to "target". Indexing is 1-based,
and the function returns -1 if the "target" string is not present in "source".
Important Note: If the "target" string is empty / missing, this function returns a
value of "1", which is generally unexpected behavior, and must be accounted for
separatetly.
]]
function str.str_find( frame )
local new_args = str._getParameters( frame.args, {'source', 'target'} )
local source_str = new_args['source'] or ''
local target_str = new_args['target'] or ''
if target_str == '' then
return 1
end
local start = mw.ustring.find( source_str, target_str, 1, true )
if start == nil then
start = -1
end
return start
end
--[[
find
This function allows one to search for a target string or pattern within another
string.
Usage:
{{#invoke:String|find|source_str|target_string|start_index|plain_flag}}
OR
{{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}}
Parameters
source: The string to search
target: The string or pattern to find within source
start: The index within the source string to start the search, defaults to 1
plain: Boolean flag indicating that target should be understood as plain
text and not as a Lua style regular expression, defaults to true
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from the parameter. In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
This function returns the first index >= "start" where "target" can be found
within "source". Indices are 1-based. If "target" is not found, then this
function returns 0. If either "source" or "target" are missing / empty, this
function also returns 0.
This function should be safe for UTF-8 strings.
]]
function str.find( frame )
local new_args = str._getParameters( frame.args, {'source', 'target', 'start', 'plain' } )
local source_str = new_args['source'] or ''
local pattern = new_args['target'] or ''
local start_pos = tonumber(new_args['start']) or 1
local plain = new_args['plain'] or true
if source_str == '' or pattern == '' then
return 0
end
plain = str._getBoolean( plain )
local start = mw.ustring.find( source_str, pattern, start_pos, plain )
if start == nil then
start = 0
end
return start
end
--[[
replace
This function allows one to replace a target string or pattern within another
string.
Usage:
{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}}
OR
{{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string|
count=replacement_count|plain=plain_flag}}
Parameters
source: The string to search
pattern: The string or pattern to find within source
replace: The replacement text
count: The number of occurences to replace, defaults to all.
plain: Boolean flag indicating that pattern should be understood as plain
text and not as a Lua style regular expression, defaults to true
]]
function str.replace( frame )
local new_args = str._getParameters( frame.args, {'source', 'pattern', 'replace', 'count', 'plain' } )
local source_str = new_args['source'] or ''
local pattern = new_args['pattern'] or ''
local replace = new_args['replace'] or ''
local count = tonumber( new_args['count'] )
local plain = new_args['plain'] or true
if source_str == '' or pattern == '' then
return source_str
end
plain = str._getBoolean( plain )
if plain then
pattern = str._escapePattern( pattern )
replace = mw.ustring.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences.
end
local result
if count ~= nil then
result = mw.ustring.gsub( source_str, pattern, replace, count )
else
result = mw.ustring.gsub( source_str, pattern, replace )
end
return result
end
--[[
simple function to pipe string.rep to templates.
]]
function str.rep( frame )
local repetitions = tonumber( frame.args[2] )
if not repetitions then
return str._error( 'function rep expects a number as second parameter, received "' .. ( frame.args[2] or '' ) .. '"' )
end
return string.rep( frame.args[1] or '', repetitions )
end
--[[
escapePattern
This function escapes special characters from a Lua string pattern. See [1]
for details on how patterns work.
[1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
Usage:
{{#invoke:String|escapePattern|pattern_string}}
Parameters
pattern_string: The pattern string to escape.
]]
function str.escapePattern( frame )
local pattern_str = frame.args[1]
if not pattern_str then
return str._error( 'No pattern string specified' )
end
local result = str._escapePattern( pattern_str )
return result
end
--[[
count
This function counts the number of occurrences of one string in another.
]]
function str.count(frame)
local args = str._getParameters(frame.args, {'source', 'pattern', 'plain'})
local source = args.source or ''
local pattern = args.pattern or ''
local plain = str._getBoolean(args.plain or true)
if plain then
pattern = str._escapePattern(pattern)
end
local _, count = mw.ustring.gsub(source, pattern, '')
return count
end
--[[
endswith
This function determines whether a string ends with another string.
]]
function str.endswith(frame)
local args = str._getParameters(frame.args, {'source', 'pattern'})
local source = args.source or ''
local pattern = args.pattern or ''
if pattern == '' then
-- All strings end with the empty string.
return "yes"
end
if mw.ustring.sub(source, -mw.ustring.len(pattern), -1) == pattern then
return "yes"
else
return ""
end
end
--[[
join
Join all non empty arguments together; the first argument is the separator.
Usage:
{{#invoke:String|join|sep|one|two|three}}
]]
function str.join(frame)
local args = {}
local sep
for _, v in ipairs( frame.args ) do
if sep then
if v ~= '' then
table.insert(args, v)
end
else
sep = v
end
end
return table.concat( args, sep or '' )
end
--[[
Helper function that populates the argument list given that user may need to use a mix of
named and unnamed parameters. This is relevant because named parameters are not
identical to unnamed parameters due to string trimming, and when dealing with strings
we sometimes want to either preserve or remove that whitespace depending on the application.
]]
function str._getParameters( frame_args, arg_list )
local new_args = {}
local index = 1
local value
for _, arg in ipairs( arg_list ) do
value = frame_args[arg]
if value == nil then
value = frame_args[index]
index = index + 1
end
new_args[arg] = value
end
return new_args
end
--[[
Helper function to handle error messages.
]]
function str._error( error_str )
local frame = mw.getCurrentFrame()
local error_category = frame.args.error_category or 'Errors reported by Module String'
local ignore_errors = frame.args.ignore_errors or false
local no_category = frame.args.no_category or false
if str._getBoolean(ignore_errors) then
return ''
end
local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>'
if error_category ~= '' and not str._getBoolean( no_category ) then
error_str = '[[Category:' .. error_category .. ']]' .. error_str
end
return error_str
end
--[[
Helper Function to interpret boolean strings
]]
function str._getBoolean( boolean_str )
local boolean_value
if type( boolean_str ) == 'string' then
boolean_str = boolean_str:lower()
if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0'
or boolean_str == '' then
boolean_value = false
else
boolean_value = true
end
elseif type( boolean_str ) == 'boolean' then
boolean_value = boolean_str
else
error( 'No boolean value found' )
end
return boolean_value
end
--[[
Helper function that escapes all pattern characters so that they will be treated
as plain text.
]]
function str._escapePattern( pattern_str )
return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" )
end
return str
6df794dd52434e0f6a372c9918f5a9dedd15f579
Module:Infobox/styles.css
828
19
42
41
2023-10-01T08:21:03Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp|small=y}} */
/*
* This TemplateStyles sheet deliberately does NOT include the full set of
* infobox styles. We are still working to migrate all of the manual
* infoboxes. See [[MediaWiki talk:Common.css/to do#Infobox]]
* DO NOT ADD THEM HERE
*/
/*
* not strictly certain these styles are necessary since the modules now
* exclusively output infobox-subbox or infobox, not both
* just replicating the module faithfully
*/
.infobox-subbox {
padding: 0;
border: none;
margin: -3px;
width: auto;
min-width: 100%;
font-size: 100%;
clear: none;
float: none;
background-color: transparent;
}
.infobox-3cols-child {
margin: auto;
}
.infobox .navbar {
font-size: 100%;
}
/* T281642 */
body.skin-minerva .infobox-header,
body.skin-minerva .infobox-subheader,
body.skin-minerva .infobox-above,
body.skin-minerva .infobox-title,
body.skin-minerva .infobox-image,
body.skin-minerva .infobox-full-data,
body.skin-minerva .infobox-below {
text-align: center;
}
e8de6d96f4fde53afc4a6b0fed534405ab59b0a7
Module:List
828
20
44
43
2023-10-01T08:21:03Z
Reverie
2
1 revision imported
Scribunto
text/plain
local libUtil = require('libraryUtil')
local checkType = libUtil.checkType
local mTableTools = require('Module:TableTools')
local p = {}
local listTypes = {
['bulleted'] = true,
['unbulleted'] = true,
['horizontal'] = true,
['ordered'] = true,
['horizontal_ordered'] = true
}
function p.makeListData(listType, args)
-- Constructs a data table to be passed to p.renderList.
local data = {}
-- Classes and TemplateStyles
data.classes = {}
data.templatestyles = ''
if listType == 'horizontal' or listType == 'horizontal_ordered' then
table.insert(data.classes, 'hlist')
data.templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Hlist/styles.css' }
}
elseif listType == 'unbulleted' then
table.insert(data.classes, 'plainlist')
data.templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Plainlist/styles.css' }
}
end
table.insert(data.classes, args.class)
-- Main div style
data.style = args.style
-- Indent for horizontal lists
if listType == 'horizontal' or listType == 'horizontal_ordered' then
local indent = tonumber(args.indent)
indent = indent and indent * 1.6 or 0
if indent > 0 then
data.marginLeft = indent .. 'em'
end
end
-- List style types for ordered lists
-- This could be "1, 2, 3", "a, b, c", or a number of others. The list style
-- type is either set by the "type" attribute or the "list-style-type" CSS
-- property.
if listType == 'ordered' or listType == 'horizontal_ordered' then
data.listStyleType = args.list_style_type or args['list-style-type']
data.type = args['type']
-- Detect invalid type attributes and attempt to convert them to
-- list-style-type CSS properties.
if data.type
and not data.listStyleType
and not tostring(data.type):find('^%s*[1AaIi]%s*$')
then
data.listStyleType = data.type
data.type = nil
end
end
-- List tag type
if listType == 'ordered' or listType == 'horizontal_ordered' then
data.listTag = 'ol'
else
data.listTag = 'ul'
end
-- Start number for ordered lists
data.start = args.start
if listType == 'horizontal_ordered' then
-- Apply fix to get start numbers working with horizontal ordered lists.
local startNum = tonumber(data.start)
if startNum then
data.counterReset = 'listitem ' .. tostring(startNum - 1)
end
end
-- List style
-- ul_style and ol_style are included for backwards compatibility. No
-- distinction is made for ordered or unordered lists.
data.listStyle = args.list_style
-- List items
-- li_style is included for backwards compatibility. item_style was included
-- to be easier to understand for non-coders.
data.itemStyle = args.item_style or args.li_style
data.items = {}
for _, num in ipairs(mTableTools.numKeys(args)) do
local item = {}
item.content = args[num]
item.style = args['item' .. tostring(num) .. '_style']
or args['item_style' .. tostring(num)]
item.value = args['item' .. tostring(num) .. '_value']
or args['item_value' .. tostring(num)]
table.insert(data.items, item)
end
return data
end
function p.renderList(data)
-- Renders the list HTML.
-- Return the blank string if there are no list items.
if type(data.items) ~= 'table' or #data.items < 1 then
return ''
end
-- Render the main div tag.
local root = mw.html.create('div')
for _, class in ipairs(data.classes or {}) do
root:addClass(class)
end
root:css{['margin-left'] = data.marginLeft}
if data.style then
root:cssText(data.style)
end
-- Render the list tag.
local list = root:tag(data.listTag or 'ul')
list
:attr{start = data.start, type = data.type}
:css{
['counter-reset'] = data.counterReset,
['list-style-type'] = data.listStyleType
}
if data.listStyle then
list:cssText(data.listStyle)
end
-- Render the list items
for _, t in ipairs(data.items or {}) do
local item = list:tag('li')
if data.itemStyle then
item:cssText(data.itemStyle)
end
if t.style then
item:cssText(t.style)
end
item
:attr{value = t.value}
:wikitext(t.content)
end
return data.templatestyles .. tostring(root)
end
function p.renderTrackingCategories(args)
local isDeprecated = false -- Tracks deprecated parameters.
for k, v in pairs(args) do
k = tostring(k)
if k:find('^item_style%d+$') or k:find('^item_value%d+$') then
isDeprecated = true
break
end
end
local ret = ''
if isDeprecated then
ret = ret .. '[[Category:List templates with deprecated parameters]]'
end
return ret
end
function p.makeList(listType, args)
if not listType or not listTypes[listType] then
error(string.format(
"bad argument #1 to 'makeList' ('%s' is not a valid list type)",
tostring(listType)
), 2)
end
checkType('makeList', 2, args, 'table')
local data = p.makeListData(listType, args)
local list = p.renderList(data)
local trackingCategories = p.renderTrackingCategories(args)
return list .. trackingCategories
end
for listType in pairs(listTypes) do
p[listType] = function (frame)
local mArguments = require('Module:Arguments')
local origArgs = mArguments.getArgs(frame, {
valueFunc = function (key, value)
if not value or not mw.ustring.find(value, '%S') then return nil end
if mw.ustring.find(value, '^%s*[%*#;:]') then
return value
else
return value:match('^%s*(.-)%s*$')
end
return nil
end
})
-- Copy all the arguments to a new table, for faster indexing.
local args = {}
for k, v in pairs(origArgs) do
args[k] = v
end
return p.makeList(listType, args)
end
end
return p
7a4f36a6e9cd56370bdd8207d23694124821dc1a
Module:TableTools
828
21
46
45
2023-10-01T08:21:04Z
Reverie
2
1 revision imported
Scribunto
text/plain
------------------------------------------------------------------------------------
-- TableTools --
-- --
-- This module includes a number of functions for dealing with Lua tables. --
-- It is a meta-module, meant to be called from other Lua modules, and should not --
-- be called directly from #invoke. --
------------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local p = {}
-- Define often-used variables and functions.
local floor = math.floor
local infinity = math.huge
local checkType = libraryUtil.checkType
local checkTypeMulti = libraryUtil.checkTypeMulti
------------------------------------------------------------------------------------
-- isPositiveInteger
--
-- This function returns true if the given value is a positive integer, and false
-- if not. Although it doesn't operate on tables, it is included here as it is
-- useful for determining whether a given table key is in the array part or the
-- hash part of a table.
------------------------------------------------------------------------------------
function p.isPositiveInteger(v)
return type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity
end
------------------------------------------------------------------------------------
-- isNan
--
-- This function returns true if the given number is a NaN value, and false if
-- not. Although it doesn't operate on tables, it is included here as it is useful
-- for determining whether a value can be a valid table key. Lua will generate an
-- error if a NaN is used as a table key.
------------------------------------------------------------------------------------
function p.isNan(v)
return type(v) == 'number' and v ~= v
end
------------------------------------------------------------------------------------
-- shallowClone
--
-- This returns a clone of a table. The value returned is a new table, but all
-- subtables and functions are shared. Metamethods are respected, but the returned
-- table will have no metatable of its own.
------------------------------------------------------------------------------------
function p.shallowClone(t)
checkType('shallowClone', 1, t, 'table')
local ret = {}
for k, v in pairs(t) do
ret[k] = v
end
return ret
end
------------------------------------------------------------------------------------
-- removeDuplicates
--
-- This removes duplicate values from an array. Non-positive-integer keys are
-- ignored. The earliest value is kept, and all subsequent duplicate values are
-- removed, but otherwise the array order is unchanged.
------------------------------------------------------------------------------------
function p.removeDuplicates(arr)
checkType('removeDuplicates', 1, arr, 'table')
local isNan = p.isNan
local ret, exists = {}, {}
for _, v in ipairs(arr) do
if isNan(v) then
-- NaNs can't be table keys, and they are also unique, so we don't need to check existence.
ret[#ret + 1] = v
else
if not exists[v] then
ret[#ret + 1] = v
exists[v] = true
end
end
end
return ret
end
------------------------------------------------------------------------------------
-- numKeys
--
-- This takes a table and returns an array containing the numbers of any numerical
-- keys that have non-nil values, sorted in numerical order.
------------------------------------------------------------------------------------
function p.numKeys(t)
checkType('numKeys', 1, t, 'table')
local isPositiveInteger = p.isPositiveInteger
local nums = {}
for k in pairs(t) do
if isPositiveInteger(k) then
nums[#nums + 1] = k
end
end
table.sort(nums)
return nums
end
------------------------------------------------------------------------------------
-- affixNums
--
-- This takes a table and returns an array containing the numbers of keys with the
-- specified prefix and suffix. For example, for the table
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", affixNums will return
-- {1, 3, 6}.
------------------------------------------------------------------------------------
function p.affixNums(t, prefix, suffix)
checkType('affixNums', 1, t, 'table')
checkType('affixNums', 2, prefix, 'string', true)
checkType('affixNums', 3, suffix, 'string', true)
local function cleanPattern(s)
-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.
return s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')
end
prefix = prefix or ''
suffix = suffix or ''
prefix = cleanPattern(prefix)
suffix = cleanPattern(suffix)
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'
local nums = {}
for k in pairs(t) do
if type(k) == 'string' then
local num = mw.ustring.match(k, pattern)
if num then
nums[#nums + 1] = tonumber(num)
end
end
end
table.sort(nums)
return nums
end
------------------------------------------------------------------------------------
-- numData
--
-- Given a table with keys like {"foo1", "bar1", "foo2", "baz2"}, returns a table
-- of subtables in the format
-- {[1] = {foo = 'text', bar = 'text'}, [2] = {foo = 'text', baz = 'text'}}.
-- Keys that don't end with an integer are stored in a subtable named "other". The
-- compress option compresses the table so that it can be iterated over with
-- ipairs.
------------------------------------------------------------------------------------
function p.numData(t, compress)
checkType('numData', 1, t, 'table')
checkType('numData', 2, compress, 'boolean', true)
local ret = {}
for k, v in pairs(t) do
local prefix, num = mw.ustring.match(tostring(k), '^([^0-9]*)([1-9][0-9]*)$')
if num then
num = tonumber(num)
local subtable = ret[num] or {}
if prefix == '' then
-- Positional parameters match the blank string; put them at the start of the subtable instead.
prefix = 1
end
subtable[prefix] = v
ret[num] = subtable
else
local subtable = ret.other or {}
subtable[k] = v
ret.other = subtable
end
end
if compress then
local other = ret.other
ret = p.compressSparseArray(ret)
ret.other = other
end
return ret
end
------------------------------------------------------------------------------------
-- compressSparseArray
--
-- This takes an array with one or more nil values, and removes the nil values
-- while preserving the order, so that the array can be safely traversed with
-- ipairs.
------------------------------------------------------------------------------------
function p.compressSparseArray(t)
checkType('compressSparseArray', 1, t, 'table')
local ret = {}
local nums = p.numKeys(t)
for _, num in ipairs(nums) do
ret[#ret + 1] = t[num]
end
return ret
end
------------------------------------------------------------------------------------
-- sparseIpairs
--
-- This is an iterator for sparse arrays. It can be used like ipairs, but can
-- handle nil values.
------------------------------------------------------------------------------------
function p.sparseIpairs(t)
checkType('sparseIpairs', 1, t, 'table')
local nums = p.numKeys(t)
local i = 0
local lim = #nums
return function ()
i = i + 1
if i <= lim then
local key = nums[i]
return key, t[key]
else
return nil, nil
end
end
end
------------------------------------------------------------------------------------
-- size
--
-- This returns the size of a key/value pair table. It will also work on arrays,
-- but for arrays it is more efficient to use the # operator.
------------------------------------------------------------------------------------
function p.size(t)
checkType('size', 1, t, 'table')
local i = 0
for _ in pairs(t) do
i = i + 1
end
return i
end
local function defaultKeySort(item1, item2)
-- "number" < "string", so numbers will be sorted before strings.
local type1, type2 = type(item1), type(item2)
if type1 ~= type2 then
return type1 < type2
elseif type1 == 'table' or type1 == 'boolean' or type1 == 'function' then
return tostring(item1) < tostring(item2)
else
return item1 < item2
end
end
------------------------------------------------------------------------------------
-- keysToList
--
-- Returns an array of the keys in a table, sorted using either a default
-- comparison function or a custom keySort function.
------------------------------------------------------------------------------------
function p.keysToList(t, keySort, checked)
if not checked then
checkType('keysToList', 1, t, 'table')
checkTypeMulti('keysToList', 2, keySort, {'function', 'boolean', 'nil'})
end
local arr = {}
local index = 1
for k in pairs(t) do
arr[index] = k
index = index + 1
end
if keySort ~= false then
keySort = type(keySort) == 'function' and keySort or defaultKeySort
table.sort(arr, keySort)
end
return arr
end
------------------------------------------------------------------------------------
-- sortedPairs
--
-- Iterates through a table, with the keys sorted using the keysToList function.
-- If there are only numerical keys, sparseIpairs is probably more efficient.
------------------------------------------------------------------------------------
function p.sortedPairs(t, keySort)
checkType('sortedPairs', 1, t, 'table')
checkType('sortedPairs', 2, keySort, 'function', true)
local arr = p.keysToList(t, keySort, true)
local i = 0
return function ()
i = i + 1
local key = arr[i]
if key ~= nil then
return key, t[key]
else
return nil, nil
end
end
end
------------------------------------------------------------------------------------
-- isArray
--
-- Returns true if the given value is a table and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArray(v)
if type(v) ~= 'table' then
return false
end
local i = 0
for _ in pairs(v) do
i = i + 1
if v[i] == nil then
return false
end
end
return true
end
------------------------------------------------------------------------------------
-- isArrayLike
--
-- Returns true if the given value is iterable and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArrayLike(v)
if not pcall(pairs, v) then
return false
end
local i = 0
for _ in pairs(v) do
i = i + 1
if v[i] == nil then
return false
end
end
return true
end
------------------------------------------------------------------------------------
-- invert
--
-- Transposes the keys and values in an array. For example, {"a", "b", "c"} ->
-- {a = 1, b = 2, c = 3}. Duplicates are not supported (result values refer to
-- the index of the last duplicate) and NaN values are ignored.
------------------------------------------------------------------------------------
function p.invert(arr)
checkType("invert", 1, arr, "table")
local isNan = p.isNan
local map = {}
for i, v in ipairs(arr) do
if not isNan(v) then
map[v] = i
end
end
return map
end
------------------------------------------------------------------------------------
-- listToSet
--
-- Creates a set from the array part of the table. Indexing the set by any of the
-- values of the array returns true. For example, {"a", "b", "c"} ->
-- {a = true, b = true, c = true}. NaN values are ignored as Lua considers them
-- never equal to any value (including other NaNs or even themselves).
------------------------------------------------------------------------------------
function p.listToSet(arr)
checkType("listToSet", 1, arr, "table")
local isNan = p.isNan
local set = {}
for _, v in ipairs(arr) do
if not isNan(v) then
set[v] = true
end
end
return set
end
------------------------------------------------------------------------------------
-- deepCopy
--
-- Recursive deep copy function. Preserves identities of subtables.
------------------------------------------------------------------------------------
local function _deepCopy(orig, includeMetatable, already_seen)
-- Stores copies of tables indexed by the original table.
already_seen = already_seen or {}
local copy = already_seen[orig]
if copy ~= nil then
return copy
end
if type(orig) == 'table' then
copy = {}
for orig_key, orig_value in pairs(orig) do
copy[_deepCopy(orig_key, includeMetatable, already_seen)] = _deepCopy(orig_value, includeMetatable, already_seen)
end
already_seen[orig] = copy
if includeMetatable then
local mt = getmetatable(orig)
if mt ~= nil then
local mt_copy = _deepCopy(mt, includeMetatable, already_seen)
setmetatable(copy, mt_copy)
already_seen[mt] = mt_copy
end
end
else -- number, string, boolean, etc
copy = orig
end
return copy
end
function p.deepCopy(orig, noMetatable, already_seen)
checkType("deepCopy", 3, already_seen, "table", true)
return _deepCopy(orig, not noMetatable, already_seen)
end
------------------------------------------------------------------------------------
-- sparseConcat
--
-- Concatenates all values in the table that are indexed by a number, in order.
-- sparseConcat{a, nil, c, d} => "acd"
-- sparseConcat{nil, b, c, d} => "bcd"
------------------------------------------------------------------------------------
function p.sparseConcat(t, sep, i, j)
local arr = {}
local arr_i = 0
for _, v in p.sparseIpairs(t) do
arr_i = arr_i + 1
arr[arr_i] = v
end
return table.concat(arr, sep, i, j)
end
------------------------------------------------------------------------------------
-- length
--
-- Finds the length of an array, or of a quasi-array with keys such as "data1",
-- "data2", etc., using an exponential search algorithm. It is similar to the
-- operator #, but may return a different value when there are gaps in the array
-- portion of the table. Intended to be used on data loaded with mw.loadData. For
-- other tables, use #.
-- Note: #frame.args in frame object always be set to 0, regardless of the number
-- of unnamed template parameters, so use this function for frame.args.
------------------------------------------------------------------------------------
function p.length(t, prefix)
-- requiring module inline so that [[Module:Exponential search]] which is
-- only needed by this one function doesn't get millions of transclusions
local expSearch = require("Module:Exponential search")
checkType('length', 1, t, 'table')
checkType('length', 2, prefix, 'string', true)
return expSearch(function (i)
local key
if prefix then
key = prefix .. tostring(i)
else
key = i
end
return t[key] ~= nil
end) or 0
end
------------------------------------------------------------------------------------
-- inArray
--
-- Returns true if valueToFind is a member of the array, and false otherwise.
------------------------------------------------------------------------------------
function p.inArray(arr, valueToFind)
checkType("inArray", 1, arr, "table")
-- if valueToFind is nil, error?
for _, v in ipairs(arr) do
if v == valueToFind then
return true
end
end
return false
end
return p
085e7094ac84eb0132ee65822cf3f69cd8ba3d81
Template:Tlx
10
22
48
47
2023-10-01T08:21:04Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Template link expanded]]
{{Redirect category shell|
{{R from move}}
}}
1fec988ceb46cb324af228aac45d7cd25fcc9008
Template:Template link expanded
10
23
50
49
2023-10-01T08:21:04Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#Invoke:Template link general|main|code=on}}<noinclude>
{{Documentation|1=Template:Tlg/doc
|content = {{tlg/doc|tlx}}
}}
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
6c99696fee02f1da368ed20d2504e19bc15b1c13
Module:Template link general
828
24
52
51
2023-10-01T08:21:05Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This implements Template:Tlg
local getArgs = require('Module:Arguments').getArgs
local p = {}
-- Is a string non-empty?
local function _ne(s)
return s ~= nil and s ~= ""
end
local nw = mw.text.nowiki
local function addTemplate(s)
local i, _ = s:find(':', 1, true)
if i == nil then
return 'Template:' .. s
end
local ns = s:sub(1, i - 1)
if ns == '' or mw.site.namespaces[ns] then
return s
else
return 'Template:' .. s
end
end
local function trimTemplate(s)
local needle = 'template:'
if s:sub(1, needle:len()):lower() == needle then
return s:sub(needle:len() + 1)
else
return s
end
end
local function linkTitle(args)
if _ne(args.nolink) then
return args['1']
end
local titleObj
local titlePart = '[['
if args['1'] then
-- This handles :Page and other NS
titleObj = mw.title.new(args['1'], 'Template')
else
titleObj = mw.title.getCurrentTitle()
end
titlePart = titlePart .. (titleObj ~= nil and titleObj.fullText or
addTemplate(args['1']))
local textPart = args.alttext
if not _ne(textPart) then
if titleObj ~= nil then
textPart = titleObj:inNamespace("Template") and args['1'] or titleObj.fullText
else
-- redlink
textPart = args['1']
end
end
if _ne(args.subst) then
-- HACK: the ns thing above is probably broken
textPart = 'subst:' .. textPart
end
if _ne(args.brace) then
textPart = nw('{{') .. textPart .. nw('}}')
elseif _ne(args.braceinside) then
textPart = nw('{') .. textPart .. nw('}')
end
titlePart = titlePart .. '|' .. textPart .. ']]'
if _ne(args.braceinside) then
titlePart = nw('{') .. titlePart .. nw('}')
end
return titlePart
end
function p.main(frame)
local args = getArgs(frame, {
trim = true,
removeBlanks = false
})
return p._main(args)
end
function p._main(args)
local bold = _ne(args.bold) or _ne(args.boldlink) or _ne(args.boldname)
local italic = _ne(args.italic) or _ne(args.italics)
local dontBrace = _ne(args.brace) or _ne(args.braceinside)
local code = _ne(args.code) or _ne(args.tt)
local show_result = _ne(args._show_result)
local expand = _ne(args._expand)
-- Build the link part
local titlePart = linkTitle(args)
if bold then titlePart = "'''" .. titlePart .. "'''" end
if _ne(args.nowrapname) then titlePart = '<span class="nowrap">' .. titlePart .. '</span>' end
-- Build the arguments
local textPart = ""
local textPartBuffer = "|"
local codeArguments = {}
local codeArgumentsString = ""
local i = 2
local j = 1
while args[i] do
local val = args[i]
if val ~= "" then
if _ne(args.nowiki) then
-- Unstrip nowiki tags first because calling nw on something that already contains nowiki tags will
-- mangle the nowiki strip marker and result in literal UNIQ...QINU showing up
val = nw(mw.text.unstripNoWiki(val))
end
local k, v = string.match(val, "(.*)=(.*)")
if not k then
codeArguments[j] = val
j = j + 1
else
codeArguments[k] = v
end
codeArgumentsString = codeArgumentsString .. textPartBuffer .. val
if italic then
val = '<span style="font-style:italic;">' .. val .. '</span>'
end
textPart = textPart .. textPartBuffer .. val
end
i = i + 1
end
-- final wrap
local ret = titlePart .. textPart
if not dontBrace then ret = nw('{{') .. ret .. nw('}}') end
if _ne(args.a) then ret = nw('*') .. ' ' .. ret end
if _ne(args.kbd) then ret = '<kbd>' .. ret .. '</kbd>' end
if code then
ret = '<code>' .. ret .. '</code>'
elseif _ne(args.plaincode) then
ret = '<code style="border:none;background:transparent;">' .. ret .. '</code>'
end
if _ne(args.nowrap) then ret = '<span class="nowrap">' .. ret .. '</span>' end
--[[ Wrap as html??
local span = mw.html.create('span')
span:wikitext(ret)
--]]
if _ne(args.debug) then ret = ret .. '\n<pre>' .. mw.text.encode(mw.dumpObject(args)) .. '</pre>' end
if show_result then
local result = mw.getCurrentFrame():expandTemplate{title = addTemplate(args[1]), args = codeArguments}
ret = ret .. " → " .. result
end
if expand then
local query = mw.text.encode('{{' .. addTemplate(args[1]) .. string.gsub(codeArgumentsString, textPartBuffer, "|") .. '}}')
local url = mw.uri.fullUrl('special:ExpandTemplates', 'wpInput=' .. query)
mw.log()
ret = ret .. " [" .. tostring(url) .. "]"
end
return ret
end
return p
c7307fa3959d308a2dd7fd2f5009c1ce6db3d122
Template:Template other
10
25
54
53
2023-10-01T08:21:05Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#switch:
<!--If no or empty "demospace" parameter then detect namespace-->
{{#if:{{{demospace|}}}
| {{lc: {{{demospace}}} }} <!--Use lower case "demospace"-->
| {{#ifeq:{{NAMESPACE}}|{{ns:Template}}
| template
| other
}}
}}
| template = {{{1|}}}
| other
| #default = {{{2|}}}
}}<!--End switch--><noinclude>
{{documentation}}
<!-- Add categories and interwikis to the /doc subpage, not here! -->
</noinclude>
06fb13d264df967b5232141067eb7d2b67372d76
Template:Clear
10
26
56
55
2023-10-01T08:21:06Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<div style="clear:{{{1|both}}};"></div><noinclude>
{{documentation}}
</noinclude>
38bab3e3d7fbd3d6800d46556e60bc6bac494d72
Template:Distinguish
10
27
58
57
2023-10-01T08:21:06Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:Distinguish|distinguish}}<noinclude><!-- splitting these lines causes {{Documentation}} template to terminate green shading when Distinguish is used in /doc pages. -->
{{Documentation}}
<!-- Add categories to the /doc subpage and interwikis to Wikidata, not here! -->
</noinclude>
f949a4cbfd6eb0ab77b832e69059a40a964b1fd8
Template:Sidebar
10
28
60
59
2023-10-01T08:21:06Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:Sidebar|sidebar}}<noinclude>
{{documentation}}</noinclude>
ab2498000a99daf324f656b0badd187b4a3e2b42
Module:Distinguish
828
29
62
61
2023-10-01T08:21:07Z
Reverie
2
1 revision imported
Scribunto
text/plain
local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local mTableTools --initialize lazily
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}
function p.distinguish(frame)
mArguments = require('Module:Arguments')
mTableTools = require('Module:TableTools')
local args = mArguments.getArgs(frame)
local selfref = args.selfref
local text = args.text
args = mTableTools.compressSparseArray(args)
return p._distinguish(args, text, selfref)
end
function p._distinguish(args, text, selfref)
checkType("_distinguish", 1, args, 'table')
if #args == 0 and not text then return '' end
local text = string.format(
'Not to be confused with %s.',
text or mHatlist.orList(args, true)
)
hnOptions = {selfref = selfref}
return mHatnote._hatnote(text, hnOptions)
end
return p
0364d14af01fc656ad1d898c5036fbd12a7ca938
Module:Effective protection expiry
828
30
64
63
2023-10-01T08:21:07Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p = {}
-- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known.
-- If no title is specified, the title of the page being displayed is used.
function p._main(action, pagename)
local title
if type(pagename) == 'table' and pagename.prefixedText then
title = pagename
elseif pagename then
title = mw.title.new(pagename)
else
title = mw.title.getCurrentTitle()
end
pagename = title.prefixedText
if action == 'autoreview' then
local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title)
return stabilitySettings and stabilitySettings.expiry or 'unknown'
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then
error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )
end
local rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename)
if rawExpiry == 'infinity' then
return 'infinity'
elseif rawExpiry == '' then
return 'unknown'
else
local year, month, day, hour, minute, second = rawExpiry:match(
'^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$'
)
if year then
return string.format(
'%s-%s-%sT%s:%s:%s',
year, month, day, hour, minute, second
)
else
error('internal error in Module:Effective protection expiry; malformed expiry timestamp')
end
end
end
setmetatable(p, { __index = function(t, k)
return function(frame)
return t._main(k, frame.args[1])
end
end })
return p
9a8c58dc2667232ed08a9b206a5d89ca8150312b
Module:Effective protection level
828
31
66
65
2023-10-01T08:21:07Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p = {}
-- Returns the permission required to perform a given action on a given title.
-- If no title is specified, the title of the page being displayed is used.
function p._main(action, pagename)
local title
if type(pagename) == 'table' and pagename.prefixedText then
title = pagename
elseif pagename then
title = mw.title.new(pagename)
else
title = mw.title.getCurrentTitle()
end
pagename = title.prefixedText
if action == 'autoreview' then
local level = mw.ext.FlaggedRevs.getStabilitySettings(title)
level = level and level.autoreview
if level == 'review' then
return 'reviewer'
elseif level ~= '' then
return level
else
return nil -- not '*'. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not '', as that would mean PC-protected but nobody can review
end
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then
error( 'First parameter must be one of edit, move, create, upload, undelete, autoreview', 2 )
end
if title.namespace == 8 then -- MediaWiki namespace
if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page
return 'interfaceadmin'
else -- any non-JS/CSS MediaWiki page
return 'sysop'
end
elseif title.namespace == 2 and title.isSubpage then
if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page
return 'interfaceadmin'
elseif title.contentModel == 'json' then -- user JSON page
return 'sysop'
end
end
if action == 'undelete' then
return 'sysop'
end
local level = title.protectionLevels[action] and title.protectionLevels[action][1]
if level == 'sysop' or level == 'editprotected' then
return 'sysop'
elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page
return 'sysop'
elseif level == 'templateeditor' then
return 'templateeditor'
elseif action == 'move' then
local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move.
if blacklistentry and not blacklistentry.params.autoconfirmed then
return 'templateeditor'
elseif title.namespace == 6 then
return 'filemover'
elseif level == 'extendedconfirmed' then
return 'extendedconfirmed'
else
return 'autoconfirmed'
end
end
local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename)
if blacklistentry then
if not blacklistentry.params.autoconfirmed then
return 'templateeditor'
elseif level == 'extendedconfirmed' then
return 'extendedconfirmed'
else
return 'autoconfirmed'
end
elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason
return 'autoconfirmed'
elseif level then
return level
elseif action == 'upload' then
return 'autoconfirmed'
elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts
return 'user'
else
return '*'
end
end
setmetatable(p, { __index = function(t, k)
return function(frame)
return t._main(k, frame.args[1])
end
end })
return p
70256a489edf6be9808031b14a7e3ef3e025da97
Module:File link
828
32
68
67
2023-10-01T08:21:08Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module provides a library for formatting file wikilinks.
local yesno = require('Module:Yesno')
local checkType = require('libraryUtil').checkType
local p = {}
function p._main(args)
checkType('_main', 1, args, 'table')
-- This is basically libraryUtil.checkTypeForNamedArg, but we are rolling our
-- own function to get the right error level.
local function checkArg(key, val, level)
if type(val) ~= 'string' then
error(string.format(
"type error in '%s' parameter of '_main' (expected string, got %s)",
key, type(val)
), level)
end
end
local ret = {}
-- Adds a positional parameter to the buffer.
local function addPositional(key)
local val = args[key]
if not val then
return nil
end
checkArg(key, val, 4)
ret[#ret + 1] = val
end
-- Adds a named parameter to the buffer. We assume that the parameter name
-- is the same as the argument key.
local function addNamed(key)
local val = args[key]
if not val then
return nil
end
checkArg(key, val, 4)
ret[#ret + 1] = key .. '=' .. val
end
-- Filename
checkArg('file', args.file, 3)
ret[#ret + 1] = 'File:' .. args.file
-- Format
if args.format then
checkArg('format', args.format)
if args.formatfile then
checkArg('formatfile', args.formatfile)
ret[#ret + 1] = args.format .. '=' .. args.formatfile
else
ret[#ret + 1] = args.format
end
end
-- Border
if yesno(args.border) then
ret[#ret + 1] = 'border'
end
addPositional('location')
addPositional('alignment')
addPositional('size')
addNamed('upright')
addNamed('link')
addNamed('alt')
addNamed('page')
addNamed('class')
addNamed('lang')
addNamed('start')
addNamed('end')
addNamed('thumbtime')
addPositional('caption')
return string.format('[[%s]]', table.concat(ret, '|'))
end
function p.main(frame)
local origArgs = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:File link'
})
if not origArgs.file then
error("'file' parameter missing from [[Template:File link]]", 0)
end
-- Copy the arguments that were passed to a new table to avoid looking up
-- every possible parameter in the frame object.
local args = {}
for k, v in pairs(origArgs) do
-- Make _BLANK a special argument to add a blank parameter. For use in
-- conditional templates etc. it is useful for blank arguments to be
-- ignored, but we still need a way to specify them so that we can do
-- things like [[File:Example.png|link=]].
if v == '_BLANK' then
v = ''
end
args[k] = v
end
return p._main(args)
end
return p
66925f088d11530f2482f04181a3baaaa0ad3d0c
Module:Format link
828
33
70
69
2023-10-01T08:21:08Z
Reverie
2
1 revision imported
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Format link
--
-- Makes a wikilink from the given link and display values. Links are escaped
-- with colons if necessary, and links to sections are detected and displayed
-- with " § " as a separator rather than the standard MediaWiki "#". Used in
-- the {{format link}} template.
--------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg
local mArguments -- lazily initialise [[Module:Arguments]]
local mError -- lazily initialise [[Module:Error]]
local yesno -- lazily initialise [[Module:Yesno]]
local p = {}
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function getArgs(frame)
-- Fetches the arguments from the parent frame. Whitespace is trimmed and
-- blanks are removed.
mArguments = require('Module:Arguments')
return mArguments.getArgs(frame, {parentOnly = true})
end
local function removeInitialColon(s)
-- Removes the initial colon from a string, if present.
return s:match('^:?(.*)')
end
local function maybeItalicize(s, shouldItalicize)
-- Italicize s if s is a string and the shouldItalicize parameter is true.
if s and shouldItalicize then
return '<i>' .. s .. '</i>'
else
return s
end
end
local function parseLink(link)
-- Parse a link and return a table with the link's components.
-- These components are:
-- - link: the link, stripped of any initial colon (always present)
-- - page: the page name (always present)
-- - section: the page name (may be nil)
-- - display: the display text, if manually entered after a pipe (may be nil)
link = removeInitialColon(link)
-- Find whether a faux display value has been added with the {{!}} magic
-- word.
local prePipe, display = link:match('^(.-)|(.*)$')
link = prePipe or link
-- Find the page, if it exists.
-- For links like [[#Bar]], the page will be nil.
local preHash, postHash = link:match('^(.-)#(.*)$')
local page
if not preHash then
-- We have a link like [[Foo]].
page = link
elseif preHash ~= '' then
-- We have a link like [[Foo#Bar]].
page = preHash
end
-- Find the section, if it exists.
local section
if postHash and postHash ~= '' then
section = postHash
end
return {
link = link,
page = page,
section = section,
display = display,
}
end
local function formatDisplay(parsed, options)
-- Formats a display string based on a parsed link table (matching the
-- output of parseLink) and an options table (matching the input options for
-- _formatLink).
local page = maybeItalicize(parsed.page, options.italicizePage)
local section = maybeItalicize(parsed.section, options.italicizeSection)
if (not section) then
return page
elseif (not page) then
return mw.ustring.format('§ %s', section)
else
return mw.ustring.format('%s § %s', page, section)
end
end
local function missingArgError(target)
mError = require('Module:Error')
return mError.error{message =
'Error: no link or target specified! ([[' .. target .. '#Errors|help]])'
}
end
--------------------------------------------------------------------------------
-- Main functions
--------------------------------------------------------------------------------
function p.formatLink(frame)
-- The formatLink export function, for use in templates.
yesno = require('Module:Yesno')
local args = getArgs(frame)
local link = args[1] or args.link
local target = args[3] or args.target
if not (link or target) then
return missingArgError('Template:Format link')
end
return p._formatLink{
link = link,
display = args[2] or args.display,
target = target,
italicizePage = yesno(args.italicizepage),
italicizeSection = yesno(args.italicizesection),
categorizeMissing = args.categorizemissing
}
end
function p._formatLink(options)
-- The formatLink export function, for use in modules.
checkType('_formatLink', 1, options, 'table')
local function check(key, expectedType) --for brevity
checkTypeForNamedArg(
'_formatLink', key, options[key], expectedType or 'string', true
)
end
check('link')
check('display')
check('target')
check('italicizePage', 'boolean')
check('italicizeSection', 'boolean')
check('categorizeMissing')
-- Normalize link and target and check that at least one is present
if options.link == '' then options.link = nil end
if options.target == '' then options.target = nil end
if not (options.link or options.target) then
return missingArgError('Module:Format link')
end
local parsed = parseLink(options.link)
local display = options.display or parsed.display
local catMissing = options.categorizeMissing
local category = ''
-- Find the display text
if not display then display = formatDisplay(parsed, options) end
-- Handle the target option if present
if options.target then
local parsedTarget = parseLink(options.target)
parsed.link = parsedTarget.link
parsed.page = parsedTarget.page
end
-- Test if page exists if a diagnostic category is specified
if catMissing and (mw.ustring.len(catMissing) > 0) then
local title = nil
if parsed.page then title = mw.title.new(parsed.page) end
if title and (not title.isExternal) then
local success, exists = pcall(function() return title.exists end)
if success and not exists then
category = mw.ustring.format('[[Category:%s]]', catMissing)
end
end
end
-- Format the result as a link
if parsed.link == display then
return mw.ustring.format('[[:%s]]%s', parsed.link, category)
else
return mw.ustring.format('[[:%s|%s]]%s', parsed.link, display, category)
end
end
--------------------------------------------------------------------------------
-- Derived convenience functions
--------------------------------------------------------------------------------
function p.formatPages(options, pages)
-- Formats an array of pages using formatLink and the given options table,
-- and returns it as an array. Nil values are not allowed.
local ret = {}
for i, page in ipairs(pages) do
ret[i] = p._formatLink{
link = page,
categorizeMissing = options.categorizeMissing,
italicizePage = options.italicizePage,
italicizeSection = options.italicizeSection
}
end
return ret
end
return p
1253bdd2683ee4badc33856bfd5499b09a7dca1f
Module:Hatnote
828
34
72
71
2023-10-01T08:21:08Z
Reverie
2
1 revision imported
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Module:Hatnote --
-- --
-- This module produces hatnote links and links to related articles. It --
-- implements the {{hatnote}} and {{format link}} meta-templates and includes --
-- helper functions for other Lua hatnote modules. --
--------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg
local mArguments -- lazily initialise [[Module:Arguments]]
local yesno -- lazily initialise [[Module:Yesno]]
local formatLink -- lazily initialise [[Module:Format link]] ._formatLink
local p = {}
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function getArgs(frame)
-- Fetches the arguments from the parent frame. Whitespace is trimmed and
-- blanks are removed.
mArguments = require('Module:Arguments')
return mArguments.getArgs(frame, {parentOnly = true})
end
local function removeInitialColon(s)
-- Removes the initial colon from a string, if present.
return s:match('^:?(.*)')
end
function p.defaultClasses(inline)
-- Provides the default hatnote classes as a space-separated string; useful
-- for hatnote-manipulation modules like [[Module:Hatnote group]].
return
(inline == 1 and 'hatnote-inline' or 'hatnote') .. ' ' ..
'navigation-not-searchable'
end
function p.disambiguate(page, disambiguator)
-- Formats a page title with a disambiguation parenthetical,
-- i.e. "Example" → "Example (disambiguation)".
checkType('disambiguate', 1, page, 'string')
checkType('disambiguate', 2, disambiguator, 'string', true)
disambiguator = disambiguator or 'disambiguation'
return mw.ustring.format('%s (%s)', page, disambiguator)
end
function p.findNamespaceId(link, removeColon)
-- Finds the namespace id (namespace number) of a link or a pagename. This
-- function will not work if the link is enclosed in double brackets. Colons
-- are trimmed from the start of the link by default. To skip colon
-- trimming, set the removeColon parameter to false.
checkType('findNamespaceId', 1, link, 'string')
checkType('findNamespaceId', 2, removeColon, 'boolean', true)
if removeColon ~= false then
link = removeInitialColon(link)
end
local namespace = link:match('^(.-):')
if namespace then
local nsTable = mw.site.namespaces[namespace]
if nsTable then
return nsTable.id
end
end
return 0
end
function p.makeWikitextError(msg, helpLink, addTrackingCategory, title)
-- Formats an error message to be returned to wikitext. If
-- addTrackingCategory is not false after being returned from
-- [[Module:Yesno]], and if we are not on a talk page, a tracking category
-- is added.
checkType('makeWikitextError', 1, msg, 'string')
checkType('makeWikitextError', 2, helpLink, 'string', true)
yesno = require('Module:Yesno')
title = title or mw.title.getCurrentTitle()
-- Make the help link text.
local helpText
if helpLink then
helpText = ' ([[' .. helpLink .. '|help]])'
else
helpText = ''
end
-- Make the category text.
local category
if not title.isTalkPage -- Don't categorise talk pages
and title.namespace ~= 2 -- Don't categorise userspace
and yesno(addTrackingCategory) ~= false -- Allow opting out
then
category = 'Hatnote templates with errors'
category = mw.ustring.format(
'[[%s:%s]]',
mw.site.namespaces[14].name,
category
)
else
category = ''
end
return mw.ustring.format(
'<strong class="error">Error: %s%s.</strong>%s',
msg,
helpText,
category
)
end
local curNs = mw.title.getCurrentTitle().namespace
p.missingTargetCat =
--Default missing target category, exported for use in related modules
((curNs == 0) or (curNs == 14)) and
'Articles with hatnote templates targeting a nonexistent page' or nil
function p.quote(title)
--Wraps titles in quotation marks. If the title starts/ends with a quotation
--mark, kerns that side as with {{-'}}
local quotationMarks = {
["'"]=true, ['"']=true, ['“']=true, ["‘"]=true, ['”']=true, ["’"]=true
}
local quoteLeft, quoteRight = -- Test if start/end are quotation marks
quotationMarks[string.sub(title, 1, 1)],
quotationMarks[string.sub(title, -1, -1)]
if quoteLeft or quoteRight then
title = mw.html.create("span"):wikitext(title)
end
if quoteLeft then title:css("padding-left", "0.15em") end
if quoteRight then title:css("padding-right", "0.15em") end
return '"' .. tostring(title) .. '"'
end
--------------------------------------------------------------------------------
-- Hatnote
--
-- Produces standard hatnote text. Implements the {{hatnote}} template.
--------------------------------------------------------------------------------
function p.hatnote(frame)
local args = getArgs(frame)
local s = args[1]
if not s then
return p.makeWikitextError(
'no text specified',
'Template:Hatnote#Errors',
args.category
)
end
return p._hatnote(s, {
extraclasses = args.extraclasses,
selfref = args.selfref
})
end
function p._hatnote(s, options)
checkType('_hatnote', 1, s, 'string')
checkType('_hatnote', 2, options, 'table', true)
options = options or {}
local inline = options.inline
local hatnote = mw.html.create(inline == 1 and 'span' or 'div')
local extraclasses
if type(options.extraclasses) == 'string' then
extraclasses = options.extraclasses
end
hatnote
:attr('role', 'note')
:addClass(p.defaultClasses(inline))
:addClass(extraclasses)
:addClass(options.selfref and 'selfref' or nil)
:wikitext(s)
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:Hatnote/styles.css' }
} .. tostring(hatnote)
end
return p
3ae1ed7094c5005ca0896395ec9a587287a0bef1
Module:Hatnote/styles.css
828
35
74
73
2023-10-01T08:21:09Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp|small=y}} */
.hatnote {
font-style: italic;
}
/* Limit structure CSS to divs because of [[Module:Hatnote inline]] */
div.hatnote {
/* @noflip */
padding-left: 1.6em;
margin-bottom: 0.5em;
}
.hatnote i {
font-style: normal;
}
/* The templatestyles element inserts a link element before hatnotes.
* TODO: Remove link if/when WMF resolves T200206 */
.hatnote + link + .hatnote {
margin-top: -0.5em;
}
44680ffd6e888866df2cdfa0341af9c7b97da94c
Module:Hatnote list
828
36
76
75
2023-10-01T08:21:09Z
Reverie
2
1 revision imported
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Module:Hatnote list --
-- --
-- This module produces and formats lists for use in hatnotes. In particular, --
-- it implements the for-see list, i.e. lists of "For X, see Y" statements, --
-- as used in {{about}}, {{redirect}}, and their variants. Also introduced --
-- are andList & orList helpers for formatting lists with those conjunctions. --
--------------------------------------------------------------------------------
local mArguments --initialize lazily
local mFormatLink = require('Module:Format link')
local mHatnote = require('Module:Hatnote')
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}
--------------------------------------------------------------------------------
-- List stringification helper functions
--
-- These functions are used for stringifying lists, usually page lists inside
-- the "Y" portion of "For X, see Y" for-see items.
--------------------------------------------------------------------------------
--default options table used across the list stringification functions
local stringifyListDefaultOptions = {
conjunction = "and",
separator = ",",
altSeparator = ";",
space = " ",
formatted = false
}
--Searches display text only
local function searchDisp(haystack, needle)
return string.find(
string.sub(haystack, (string.find(haystack, '|') or 0) + 1), needle
)
end
-- Stringifies a list generically; probably shouldn't be used directly
local function stringifyList(list, options)
-- Type-checks, defaults, and a shortcut
checkType("stringifyList", 1, list, "table")
if #list == 0 then return nil end
checkType("stringifyList", 2, options, "table", true)
options = options or {}
for k, v in pairs(stringifyListDefaultOptions) do
if options[k] == nil then options[k] = v end
end
local s = options.space
-- Format the list if requested
if options.formatted then
list = mFormatLink.formatPages(
{categorizeMissing = mHatnote.missingTargetCat}, list
)
end
-- Set the separator; if any item contains it, use the alternate separator
local separator = options.separator
for k, v in pairs(list) do
if searchDisp(v, separator) then
separator = options.altSeparator
break
end
end
-- Set the conjunction, apply Oxford comma, and force a comma if #1 has "§"
local conjunction = s .. options.conjunction .. s
if #list == 2 and searchDisp(list[1], "§") or #list > 2 then
conjunction = separator .. conjunction
end
-- Return the formatted string
return mw.text.listToText(list, separator .. s, conjunction)
end
--DRY function
function p.conjList (conj, list, fmt)
return stringifyList(list, {conjunction = conj, formatted = fmt})
end
-- Stringifies lists with "and" or "or"
function p.andList (...) return p.conjList("and", ...) end
function p.orList (...) return p.conjList("or", ...) end
--------------------------------------------------------------------------------
-- For see
--
-- Makes a "For X, see [[Y]]." list from raw parameters. Intended for the
-- {{about}} and {{redirect}} templates and their variants.
--------------------------------------------------------------------------------
--default options table used across the forSee family of functions
local forSeeDefaultOptions = {
andKeyword = 'and',
title = mw.title.getCurrentTitle().text,
otherText = 'other uses',
forSeeForm = 'For %s, see %s.',
}
--Collapses duplicate punctuation
local function punctuationCollapse (text)
local replacements = {
["%.%.$"] = ".",
["%?%.$"] = "?",
["%!%.$"] = "!",
["%.%]%]%.$"] = ".]]",
["%?%]%]%.$"] = "?]]",
["%!%]%]%.$"] = "!]]"
}
for k, v in pairs(replacements) do text = string.gsub(text, k, v) end
return text
end
-- Structures arguments into a table for stringification, & options
function p.forSeeArgsToTable (args, from, options)
-- Type-checks and defaults
checkType("forSeeArgsToTable", 1, args, 'table')
checkType("forSeeArgsToTable", 2, from, 'number', true)
from = from or 1
checkType("forSeeArgsToTable", 3, options, 'table', true)
options = options or {}
for k, v in pairs(forSeeDefaultOptions) do
if options[k] == nil then options[k] = v end
end
-- maxArg's gotten manually because getArgs() and table.maxn aren't friends
local maxArg = 0
for k, v in pairs(args) do
if type(k) == 'number' and k > maxArg then maxArg = k end
end
-- Structure the data out from the parameter list:
-- * forTable is the wrapper table, with forRow rows
-- * Rows are tables of a "use" string & a "pages" table of pagename strings
-- * Blanks are left empty for defaulting elsewhere, but can terminate list
local forTable = {}
local i = from
local terminated = false
-- If there is extra text, and no arguments are given, give nil value
-- to not produce default of "For other uses, see foo (disambiguation)"
if options.extratext and i > maxArg then return nil end
-- Loop to generate rows
repeat
-- New empty row
local forRow = {}
-- On blank use, assume list's ended & break at end of this loop
forRow.use = args[i]
if not args[i] then terminated = true end
-- New empty list of pages
forRow.pages = {}
-- Insert first pages item if present
table.insert(forRow.pages, args[i + 1])
-- If the param after next is "and", do inner loop to collect params
-- until the "and"'s stop. Blanks are ignored: "1|and||and|3" → {1, 3}
while args[i + 2] == options.andKeyword do
if args[i + 3] then
table.insert(forRow.pages, args[i + 3])
end
-- Increment to next "and"
i = i + 2
end
-- Increment to next use
i = i + 2
-- Append the row
table.insert(forTable, forRow)
until terminated or i > maxArg
return forTable
end
-- Stringifies a table as formatted by forSeeArgsToTable
function p.forSeeTableToString (forSeeTable, options)
-- Type-checks and defaults
checkType("forSeeTableToString", 1, forSeeTable, "table", true)
checkType("forSeeTableToString", 2, options, "table", true)
options = options or {}
for k, v in pairs(forSeeDefaultOptions) do
if options[k] == nil then options[k] = v end
end
-- Stringify each for-see item into a list
local strList = {}
if forSeeTable then
for k, v in pairs(forSeeTable) do
local useStr = v.use or options.otherText
local pagesStr =
p.andList(v.pages, true) or
mFormatLink._formatLink{
categorizeMissing = mHatnote.missingTargetCat,
link = mHatnote.disambiguate(options.title)
}
local forSeeStr = string.format(options.forSeeForm, useStr, pagesStr)
forSeeStr = punctuationCollapse(forSeeStr)
table.insert(strList, forSeeStr)
end
end
if options.extratext then table.insert(strList, punctuationCollapse(options.extratext..'.')) end
-- Return the concatenated list
return table.concat(strList, ' ')
end
-- Produces a "For X, see [[Y]]" string from arguments. Expects index gaps
-- but not blank/whitespace values. Ignores named args and args < "from".
function p._forSee (args, from, options)
local forSeeTable = p.forSeeArgsToTable(args, from, options)
return p.forSeeTableToString(forSeeTable, options)
end
-- As _forSee, but uses the frame.
function p.forSee (frame, from, options)
mArguments = require('Module:Arguments')
return p._forSee(mArguments.getArgs(frame), from, options)
end
return p
d0828422b1aa0d0d0092d699d059c9e882260398
Module:Navbar
828
37
78
77
2023-10-01T08:21:10Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p = {}
local cfg = mw.loadData('Module:Navbar/configuration')
local function get_title_arg(is_collapsible, template)
local title_arg = 1
if is_collapsible then title_arg = 2 end
if template then title_arg = 'template' end
return title_arg
end
local function choose_links(template, args)
-- The show table indicates the default displayed items.
-- view, talk, edit, hist, move, watch
-- TODO: Move to configuration.
local show = {true, true, true, false, false, false}
if template then
show[2] = false
show[3] = false
local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6,
talk = 2, edit = 3, hist = 4, move = 5, watch = 6}
-- TODO: Consider removing TableTools dependency.
for _, v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do
local num = index[v]
if num then show[num] = true end
end
end
local remove_edit_link = args.noedit
if remove_edit_link then show[3] = false end
return show
end
local function add_link(link_description, ul, is_mini, font_style)
local l
if link_description.url then
l = {'[', '', ']'}
else
l = {'[[', '|', ']]'}
end
ul:tag('li')
:addClass('nv-' .. link_description.full)
:wikitext(l[1] .. link_description.link .. l[2])
:tag(is_mini and 'abbr' or 'span')
:attr('title', link_description.html_title)
:cssText(font_style)
:wikitext(is_mini and link_description.mini or link_description.full)
:done()
:wikitext(l[3])
:done()
end
local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
if not title then
error(cfg.invalid_title .. title_text)
end
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
-- TODO: Get link_descriptions and show into the configuration module.
-- link_descriptions should be easier...
local link_descriptions = {
{ ['mini'] = 'v', ['full'] = 'view', ['html_title'] = 'View this template',
['link'] = title.fullText, ['url'] = false },
{ ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template',
['link'] = talkpage, ['url'] = false },
{ ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template',
['link'] = title:fullUrl('action=edit'), ['url'] = true },
{ ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template',
['link'] = title:fullUrl('action=history'), ['url'] = true },
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
['link'] = title:fullUrl('action=watch'), ['url'] = true }
}
local ul = mw.html.create('ul')
if has_brackets then
ul:addClass(cfg.classes.brackets)
:cssText(font_style)
end
for i, _ in ipairs(displayed_links) do
if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
end
return ul:done()
end
function p._navbar(args)
-- TODO: We probably don't need both fontstyle and fontcolor...
local font_style = args.fontstyle
local font_color = args.fontcolor
local is_collapsible = args.collapsible
local is_mini = args.mini
local is_plain = args.plain
local collapsible_class = nil
if is_collapsible then
collapsible_class = cfg.classes.collapsible
if not is_plain then is_mini = 1 end
if font_color then
font_style = (font_style or '') .. '; color: ' .. font_color .. ';'
end
end
local navbar_style = args.style
local div = mw.html.create():tag('div')
div
:addClass(cfg.classes.navbar)
:addClass(cfg.classes.plainlinks)
:addClass(cfg.classes.horizontal_list)
:addClass(collapsible_class) -- we made the determination earlier
:cssText(navbar_style)
if is_mini then div:addClass(cfg.classes.mini) end
local box_text = (args.text or cfg.box_text) .. ' '
-- the concatenated space guarantees the box text is separated
if not (is_mini or is_plain) then
div
:tag('span')
:addClass(cfg.classes.box_text)
:cssText(font_style)
:wikitext(box_text)
end
local template = args.template
local displayed_links = choose_links(template, args)
local has_brackets = args.brackets
local title_arg = get_title_arg(is_collapsible, template)
local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
div:node(list)
if is_collapsible then
local title_text_class
if is_mini then
title_text_class = cfg.classes.collapsible_title_mini
else
title_text_class = cfg.classes.collapsible_title_full
end
div:done()
:tag('div')
:addClass(title_text_class)
:cssText(font_style)
:wikitext(args[1])
end
local frame = mw.getCurrentFrame()
-- hlist -> navbar is best-effort to preserve old Common.css ordering.
return frame:extensionTag{
name = 'templatestyles', args = { src = cfg.hlist_templatestyles }
} .. frame:extensionTag{
name = 'templatestyles', args = { src = cfg.templatestyles }
} .. tostring(div:done())
end
function p.navbar(frame)
return p._navbar(require('Module:Arguments').getArgs(frame))
end
return p
79f907e59eaa8bbf8dd50bb751933ebeaaa7eb17
Module:Navbar/configuration
828
38
80
79
2023-10-01T08:21:10Z
Reverie
2
1 revision imported
Scribunto
text/plain
return {
['templatestyles'] = 'Module:Navbar/styles.css',
['hlist_templatestyles'] = 'Hlist/styles.css',
['box_text'] = 'This box: ', -- default text box when not plain or mini
['title_namespace'] = 'Template', -- namespace to default to for title
['invalid_title'] = 'Invalid title ',
['classes'] = { -- set a line to nil if you don't want it
['navbar'] = 'navbar',
['plainlinks'] = 'plainlinks', -- plainlinks
['horizontal_list'] = 'hlist', -- horizontal list class
['mini'] = 'navbar-mini', -- class indicating small links in the navbar
['this_box'] = 'navbar-boxtext',
['brackets'] = 'navbar-brackets',
-- 'collapsible' is the key for a class to indicate the navbar is
-- setting up the collapsible element in addition to the normal
-- navbar.
['collapsible'] = 'navbar-collapse',
['collapsible_title_mini'] = 'navbar-ct-mini',
['collapsible_title_full'] = 'navbar-ct-full'
}
}
b007c336b17ec4bcd4d5a9dca9f8cba301662b55
Module:Navbar/styles.css
828
39
82
81
2023-10-01T08:21:10Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp|small=yes}} */
.navbar {
display: inline;
font-size: 88%;
font-weight: normal;
}
.navbar-collapse {
float: left;
text-align: left;
}
.navbar-boxtext {
word-spacing: 0;
}
.navbar ul {
display: inline-block;
white-space: nowrap;
line-height: inherit;
}
.navbar-brackets::before {
margin-right: -0.125em;
content: '[ ';
}
.navbar-brackets::after {
margin-left: -0.125em;
content: ' ]';
}
.navbar li {
word-spacing: -0.125em;
}
.navbar a > span,
.navbar a > abbr {
text-decoration: inherit;
}
.navbar-mini abbr {
font-variant: small-caps;
border-bottom: none;
text-decoration: none;
cursor: inherit;
}
.navbar-ct-full {
font-size: 114%;
margin: 0 7em;
}
.navbar-ct-mini {
font-size: 114%;
margin: 0 4em;
}
9d4056f949b4f0b159e3d40dfb1a5f01e72f9571
Module:Protection banner
828
40
84
83
2023-10-01T08:21:11Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module implements {{pp-meta}} and its daughter templates such as
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.
-- Initialise necessary modules.
require('strict')
local makeFileLink = require('Module:File link')._main
local effectiveProtectionLevel = require('Module:Effective protection level')._main
local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main
local yesno = require('Module:Yesno')
-- Lazily initialise modules and objects we don't always need.
local getArgs, makeMessageBox, lang
-- Set constants.
local CONFIG_MODULE = 'Module:Protection banner/config'
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function makeCategoryLink(cat, sort)
if cat then
return string.format(
'[[%s:%s|%s]]',
mw.site.namespaces[14].name,
cat,
sort
)
end
end
-- Validation function for the expiry and the protection date
local function validateDate(dateString, dateType)
if not lang then
lang = mw.language.getContentLanguage()
end
local success, result = pcall(lang.formatDate, lang, 'U', dateString)
if success then
result = tonumber(result)
if result then
return result
end
end
error(string.format(
'invalid %s: %s',
dateType,
tostring(dateString)
), 4)
end
local function makeFullUrl(page, query, display)
return string.format(
'[%s %s]',
tostring(mw.uri.fullUrl(page, query)),
display
)
end
-- Given a directed graph formatted as node -> table of direct successors,
-- get a table of all nodes reachable from a given node (though always
-- including the given node).
local function getReachableNodes(graph, start)
local toWalk, retval = {[start] = true}, {}
while true do
-- Can't use pairs() since we're adding and removing things as we're iterating
local k = next(toWalk) -- This always gets the "first" key
if k == nil then
return retval
end
toWalk[k] = nil
retval[k] = true
for _,v in ipairs(graph[k]) do
if not retval[v] then
toWalk[v] = true
end
end
end
end
--------------------------------------------------------------------------------
-- Protection class
--------------------------------------------------------------------------------
local Protection = {}
Protection.__index = Protection
Protection.supportedActions = {
edit = true,
move = true,
autoreview = true,
upload = true
}
Protection.bannerConfigFields = {
'text',
'explanation',
'tooltip',
'alt',
'link',
'image'
}
function Protection.new(args, cfg, title)
local obj = {}
obj._cfg = cfg
obj.title = title or mw.title.getCurrentTitle()
-- Set action
if not args.action then
obj.action = 'edit'
elseif Protection.supportedActions[args.action] then
obj.action = args.action
else
error(string.format(
'invalid action: %s',
tostring(args.action)
), 3)
end
-- Set level
obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title)
if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then
-- Users need to be autoconfirmed to move pages anyway, so treat
-- semi-move-protected pages as unprotected.
obj.level = '*'
end
-- Set expiry
local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)
if effectiveExpiry == 'infinity' then
obj.expiry = 'indef'
elseif effectiveExpiry ~= 'unknown' then
obj.expiry = validateDate(effectiveExpiry, 'expiry date')
end
-- Set reason
if args[1] then
obj.reason = mw.ustring.lower(args[1])
if obj.reason:find('|') then
error('reasons cannot contain the pipe character ("|")', 3)
end
end
-- Set protection date
if args.date then
obj.protectionDate = validateDate(args.date, 'protection date')
end
-- Set banner config
do
obj.bannerConfig = {}
local configTables = {}
if cfg.banners[obj.action] then
configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason]
end
if cfg.defaultBanners[obj.action] then
configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level]
configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default
end
configTables[#configTables + 1] = cfg.masterBanner
for i, field in ipairs(Protection.bannerConfigFields) do
for j, t in ipairs(configTables) do
if t[field] then
obj.bannerConfig[field] = t[field]
break
end
end
end
end
return setmetatable(obj, Protection)
end
function Protection:isUserScript()
-- Whether the page is a user JavaScript or CSS page.
local title = self.title
return title.namespace == 2 and (
title.contentModel == 'javascript' or title.contentModel == 'css'
)
end
function Protection:isProtected()
return self.level ~= '*'
end
function Protection:shouldShowLock()
-- Whether we should output a banner/padlock
return self:isProtected() and not self:isUserScript()
end
-- Whether this page needs a protection category.
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
function Protection:isTemporary()
return type(self.expiry) == 'number'
end
function Protection:makeProtectionCategory()
if not self:shouldHaveProtectionCategory() then
return ''
end
local cfg = self._cfg
local title = self.title
-- Get the expiry key fragment.
local expiryFragment
if self.expiry == 'indef' then
expiryFragment = self.expiry
elseif type(self.expiry) == 'number' then
expiryFragment = 'temp'
end
-- Get the namespace key fragment.
local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]
if not namespaceFragment and title.namespace % 2 == 1 then
namespaceFragment = 'talk'
end
-- Define the order that key fragments are tested in. This is done with an
-- array of tables containing the value to be tested, along with its
-- position in the cfg.protectionCategories table.
local order = {
{val = expiryFragment, keypos = 1},
{val = namespaceFragment, keypos = 2},
{val = self.reason, keypos = 3},
{val = self.level, keypos = 4},
{val = self.action, keypos = 5}
}
--[[
-- The old protection templates used an ad-hoc protection category system,
-- with some templates prioritising namespaces in their categories, and
-- others prioritising the protection reason. To emulate this in this module
-- we use the config table cfg.reasonsWithNamespacePriority to set the
-- reasons for which namespaces have priority over protection reason.
-- If we are dealing with one of those reasons, move the namespace table to
-- the end of the order table, i.e. give it highest priority. If not, the
-- reason should have highest priority, so move that to the end of the table
-- instead.
--]]
table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))
--[[
-- Define the attempt order. Inactive subtables (subtables with nil "value"
-- fields) are moved to the end, where they will later be given the key
-- "all". This is to cut down on the number of table lookups in
-- cfg.protectionCategories, which grows exponentially with the number of
-- non-nil keys. We keep track of the number of active subtables with the
-- noActive parameter.
--]]
local noActive, attemptOrder
do
local active, inactive = {}, {}
for i, t in ipairs(order) do
if t.val then
active[#active + 1] = t
else
inactive[#inactive + 1] = t
end
end
noActive = #active
attemptOrder = active
for i, t in ipairs(inactive) do
attemptOrder[#attemptOrder + 1] = t
end
end
--[[
-- Check increasingly generic key combinations until we find a match. If a
-- specific category exists for the combination of key fragments we are
-- given, that match will be found first. If not, we keep trying different
-- key fragment combinations until we match using the key
-- "all-all-all-all-all".
--
-- To generate the keys, we index the key subtables using a binary matrix
-- with indexes i and j. j is only calculated up to the number of active
-- subtables. For example, if there were three active subtables, the matrix
-- would look like this, with 0 corresponding to the key fragment "all", and
-- 1 corresponding to other key fragments.
--
-- j 1 2 3
-- i
-- 1 1 1 1
-- 2 0 1 1
-- 3 1 0 1
-- 4 0 0 1
-- 5 1 1 0
-- 6 0 1 0
-- 7 1 0 0
-- 8 0 0 0
--
-- Values of j higher than the number of active subtables are set
-- to the string "all".
--
-- A key for cfg.protectionCategories is constructed for each value of i.
-- The position of the value in the key is determined by the keypos field in
-- each subtable.
--]]
local cats = cfg.protectionCategories
for i = 1, 2^noActive do
local key = {}
for j, t in ipairs(attemptOrder) do
if j > noActive then
key[t.keypos] = 'all'
else
local quotient = i / 2 ^ (j - 1)
quotient = math.ceil(quotient)
if quotient % 2 == 1 then
key[t.keypos] = t.val
else
key[t.keypos] = 'all'
end
end
end
key = table.concat(key, '|')
local attempt = cats[key]
if attempt then
return makeCategoryLink(attempt, title.text)
end
end
return ''
end
function Protection:isIncorrect()
local expiry = self.expiry
return not self:shouldHaveProtectionCategory()
or type(expiry) == 'number' and expiry < os.time()
end
function Protection:isTemplateProtectedNonTemplate()
local action, namespace = self.action, self.title.namespace
return self.level == 'templateeditor'
and (
(action ~= 'edit' and action ~= 'move')
or (namespace ~= 10 and namespace ~= 828)
)
end
function Protection:makeCategoryLinks()
local msg = self._cfg.msg
local ret = {self:makeProtectionCategory()}
if self:isIncorrect() then
ret[#ret + 1] = makeCategoryLink(
msg['tracking-category-incorrect'],
self.title.text
)
end
if self:isTemplateProtectedNonTemplate() then
ret[#ret + 1] = makeCategoryLink(
msg['tracking-category-template'],
self.title.text
)
end
return table.concat(ret)
end
--------------------------------------------------------------------------------
-- Blurb class
--------------------------------------------------------------------------------
local Blurb = {}
Blurb.__index = Blurb
Blurb.bannerTextFields = {
text = true,
explanation = true,
tooltip = true,
alt = true,
link = true
}
function Blurb.new(protectionObj, args, cfg)
return setmetatable({
_cfg = cfg,
_protectionObj = protectionObj,
_args = args
}, Blurb)
end
-- Private methods --
function Blurb:_formatDate(num)
-- Formats a Unix timestamp into dd Month, YYYY format.
lang = lang or mw.language.getContentLanguage()
local success, date = pcall(
lang.formatDate,
lang,
self._cfg.msg['expiry-date-format'] or 'j F Y',
'@' .. tostring(num)
)
if success then
return date
end
end
function Blurb:_getExpandedMessage(msgKey)
return self:_substituteParameters(self._cfg.msg[msgKey])
end
function Blurb:_substituteParameters(msg)
if not self._params then
local parameterFuncs = {}
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter
parameterFuncs.EXPIRY = self._makeExpiryParameter
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter
parameterFuncs.IMAGELINK = self._makeImageLinkParameter
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter
parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter
parameterFuncs.PAGETYPE = self._makePagetypeParameter
parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
parameterFuncs.TALKPAGE = self._makeTalkPageParameter
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter
parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter
parameterFuncs.VANDAL = self._makeVandalTemplateParameter
self._params = setmetatable({}, {
__index = function (t, k)
local param
if parameterFuncs[k] then
param = parameterFuncs[k](self)
end
param = param or ''
t[k] = param
return param
end
})
end
msg = msg:gsub('${(%u+)}', self._params)
return msg
end
function Blurb:_makeCurrentVersionParameter()
-- A link to the page history or the move log, depending on the kind of
-- protection.
local pagename = self._protectionObj.title.prefixedText
if self._protectionObj.action == 'move' then
-- We need the move log link.
return makeFullUrl(
'Special:Log',
{type = 'move', page = pagename},
self:_getExpandedMessage('current-version-move-display')
)
else
-- We need the history link.
return makeFullUrl(
pagename,
{action = 'history'},
self:_getExpandedMessage('current-version-edit-display')
)
end
end
function Blurb:_makeEditRequestParameter()
local mEditRequest = require('Module:Submit an edit request')
local action = self._protectionObj.action
local level = self._protectionObj.level
-- Get the edit request type.
local requestType
if action == 'edit' then
if level == 'autoconfirmed' then
requestType = 'semi'
elseif level == 'extendedconfirmed' then
requestType = 'extended'
elseif level == 'templateeditor' then
requestType = 'template'
end
end
requestType = requestType or 'full'
-- Get the display value.
local display = self:_getExpandedMessage('edit-request-display')
return mEditRequest._link{type = requestType, display = display}
end
function Blurb:_makeExpiryParameter()
local expiry = self._protectionObj.expiry
if type(expiry) == 'number' then
return self:_formatDate(expiry)
else
return expiry
end
end
function Blurb:_makeExplanationBlurbParameter()
-- Cover special cases first.
if self._protectionObj.title.namespace == 8 then
-- MediaWiki namespace
return self:_getExpandedMessage('explanation-blurb-nounprotect')
end
-- Get explanation blurb table keys
local action = self._protectionObj.action
local level = self._protectionObj.level
local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject'
-- Find the message in the explanation blurb table and substitute any
-- parameters.
local explanations = self._cfg.explanationBlurbs
local msg
if explanations[action][level] and explanations[action][level][talkKey] then
msg = explanations[action][level][talkKey]
elseif explanations[action][level] and explanations[action][level].default then
msg = explanations[action][level].default
elseif explanations[action].default and explanations[action].default[talkKey] then
msg = explanations[action].default[talkKey]
elseif explanations[action].default and explanations[action].default.default then
msg = explanations[action].default.default
else
error(string.format(
'could not find explanation blurb for action "%s", level "%s" and talk key "%s"',
action,
level,
talkKey
), 8)
end
return self:_substituteParameters(msg)
end
function Blurb:_makeImageLinkParameter()
local imageLinks = self._cfg.imageLinks
local action = self._protectionObj.action
local level = self._protectionObj.level
local msg
if imageLinks[action][level] then
msg = imageLinks[action][level]
elseif imageLinks[action].default then
msg = imageLinks[action].default
else
msg = imageLinks.edit.default
end
return self:_substituteParameters(msg)
end
function Blurb:_makeIntroBlurbParameter()
if self._protectionObj:isTemporary() then
return self:_getExpandedMessage('intro-blurb-expiry')
else
return self:_getExpandedMessage('intro-blurb-noexpiry')
end
end
function Blurb:_makeIntroFragmentParameter()
if self._protectionObj:isTemporary() then
return self:_getExpandedMessage('intro-fragment-expiry')
else
return self:_getExpandedMessage('intro-fragment-noexpiry')
end
end
function Blurb:_makePagetypeParameter()
local pagetypes = self._cfg.pagetypes
return pagetypes[self._protectionObj.title.namespace]
or pagetypes.default
or error('no default pagetype defined', 8)
end
function Blurb:_makeProtectionBlurbParameter()
local protectionBlurbs = self._cfg.protectionBlurbs
local action = self._protectionObj.action
local level = self._protectionObj.level
local msg
if protectionBlurbs[action][level] then
msg = protectionBlurbs[action][level]
elseif protectionBlurbs[action].default then
msg = protectionBlurbs[action].default
elseif protectionBlurbs.edit.default then
msg = protectionBlurbs.edit.default
else
error('no protection blurb defined for protectionBlurbs.edit.default', 8)
end
return self:_substituteParameters(msg)
end
function Blurb:_makeProtectionDateParameter()
local protectionDate = self._protectionObj.protectionDate
if type(protectionDate) == 'number' then
return self:_formatDate(protectionDate)
else
return protectionDate
end
end
function Blurb:_makeProtectionLevelParameter()
local protectionLevels = self._cfg.protectionLevels
local action = self._protectionObj.action
local level = self._protectionObj.level
local msg
if protectionLevels[action][level] then
msg = protectionLevels[action][level]
elseif protectionLevels[action].default then
msg = protectionLevels[action].default
elseif protectionLevels.edit.default then
msg = protectionLevels.edit.default
else
error('no protection level defined for protectionLevels.edit.default', 8)
end
return self:_substituteParameters(msg)
end
function Blurb:_makeProtectionLogParameter()
local pagename = self._protectionObj.title.prefixedText
if self._protectionObj.action == 'autoreview' then
-- We need the pending changes log.
return makeFullUrl(
'Special:Log',
{type = 'stable', page = pagename},
self:_getExpandedMessage('pc-log-display')
)
else
-- We need the protection log.
return makeFullUrl(
'Special:Log',
{type = 'protect', page = pagename},
self:_getExpandedMessage('protection-log-display')
)
end
end
function Blurb:_makeTalkPageParameter()
return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._protectionObj.title.namespace].talk.name,
self._protectionObj.title.text,
self._args.section or 'top',
self:_getExpandedMessage('talk-page-link-display')
)
end
function Blurb:_makeTooltipBlurbParameter()
if self._protectionObj:isTemporary() then
return self:_getExpandedMessage('tooltip-blurb-expiry')
else
return self:_getExpandedMessage('tooltip-blurb-noexpiry')
end
end
function Blurb:_makeTooltipFragmentParameter()
if self._protectionObj:isTemporary() then
return self:_getExpandedMessage('tooltip-fragment-expiry')
else
return self:_getExpandedMessage('tooltip-fragment-noexpiry')
end
end
function Blurb:_makeVandalTemplateParameter()
return mw.getCurrentFrame():expandTemplate{
title="vandal-m",
args={self._args.user or self._protectionObj.title.baseText}
}
end
-- Public methods --
function Blurb:makeBannerText(key)
-- Validate input.
if not key or not Blurb.bannerTextFields[key] then
error(string.format(
'"%s" is not a valid banner config field',
tostring(key)
), 2)
end
-- Generate the text.
local msg = self._protectionObj.bannerConfig[key]
if type(msg) == 'string' then
return self:_substituteParameters(msg)
elseif type(msg) == 'function' then
msg = msg(self._protectionObj, self._args)
if type(msg) ~= 'string' then
error(string.format(
'bad output from banner config function with key "%s"'
.. ' (expected string, got %s)',
tostring(key),
type(msg)
), 4)
end
return self:_substituteParameters(msg)
end
end
--------------------------------------------------------------------------------
-- BannerTemplate class
--------------------------------------------------------------------------------
local BannerTemplate = {}
BannerTemplate.__index = BannerTemplate
function BannerTemplate.new(protectionObj, cfg)
local obj = {}
obj._cfg = cfg
-- Set the image filename.
local imageFilename = protectionObj.bannerConfig.image
if imageFilename then
obj._imageFilename = imageFilename
else
-- If an image filename isn't specified explicitly in the banner config,
-- generate it from the protection status and the namespace.
local action = protectionObj.action
local level = protectionObj.level
local namespace = protectionObj.title.namespace
local reason = protectionObj.reason
-- Deal with special cases first.
if (
namespace == 10
or namespace == 828
or reason and obj._cfg.indefImageReasons[reason]
)
and action == 'edit'
and level == 'sysop'
and not protectionObj:isTemporary()
then
-- Fully protected modules and templates get the special red "indef"
-- padlock.
obj._imageFilename = obj._cfg.msg['image-filename-indef']
else
-- Deal with regular protection types.
local images = obj._cfg.images
if images[action] then
if images[action][level] then
obj._imageFilename = images[action][level]
elseif images[action].default then
obj._imageFilename = images[action].default
end
end
end
end
return setmetatable(obj, BannerTemplate)
end
function BannerTemplate:renderImage()
local filename = self._imageFilename
or self._cfg.msg['image-filename-default']
or 'Transparent.gif'
return makeFileLink{
file = filename,
size = (self.imageWidth or 20) .. 'px',
alt = self._imageAlt,
link = self._imageLink,
caption = self.imageCaption
}
end
--------------------------------------------------------------------------------
-- Banner class
--------------------------------------------------------------------------------
local Banner = setmetatable({}, BannerTemplate)
Banner.__index = Banner
function Banner.new(protectionObj, blurbObj, cfg)
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
obj.imageWidth = 40
obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip.
obj._reasonText = blurbObj:makeBannerText('text')
obj._explanationText = blurbObj:makeBannerText('explanation')
obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing.
return setmetatable(obj, Banner)
end
function Banner:__tostring()
-- Renders the banner.
makeMessageBox = makeMessageBox or require('Module:Message box').main
local reasonText = self._reasonText or error('no reason text set', 2)
local explanationText = self._explanationText
local mbargs = {
page = self._page,
type = 'protection',
image = self:renderImage(),
text = string.format(
"'''%s'''%s",
reasonText,
explanationText and '<br />' .. explanationText or ''
)
}
return makeMessageBox('mbox', mbargs)
end
--------------------------------------------------------------------------------
-- Padlock class
--------------------------------------------------------------------------------
local Padlock = setmetatable({}, BannerTemplate)
Padlock.__index = Padlock
function Padlock.new(protectionObj, blurbObj, cfg)
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
obj.imageWidth = 20
obj.imageCaption = blurbObj:makeBannerText('tooltip')
obj._imageAlt = blurbObj:makeBannerText('alt')
obj._imageLink = blurbObj:makeBannerText('link')
obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action]
or cfg.padlockIndicatorNames.default
or 'pp-default'
return setmetatable(obj, Padlock)
end
function Padlock:__tostring()
local frame = mw.getCurrentFrame()
-- The nowiki tag helps prevent whitespace at the top of articles.
return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{
name = 'indicator',
args = {name = self._indicatorName},
content = self:renderImage()
}
end
--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------
local p = {}
function p._exportClasses()
-- This is used for testing purposes.
return {
Protection = Protection,
Blurb = Blurb,
BannerTemplate = BannerTemplate,
Banner = Banner,
Padlock = Padlock,
}
end
function p._main(args, cfg, title)
args = args or {}
cfg = cfg or require(CONFIG_MODULE)
local protectionObj = Protection.new(args, cfg, title)
local ret = {}
-- If a page's edit protection is equally or more restrictive than its
-- protection from some other action, then don't bother displaying anything
-- for the other action (except categories).
if not yesno(args.catonly) and (protectionObj.action == 'edit' or
args.demolevel or
not getReachableNodes(
cfg.hierarchy,
protectionObj.level
)[effectiveProtectionLevel('edit', protectionObj.title)])
then
-- Initialise the blurb object
local blurbObj = Blurb.new(protectionObj, args, cfg)
-- Render the banner
if protectionObj:shouldShowLock() then
ret[#ret + 1] = tostring(
(yesno(args.small) and Padlock or Banner)
.new(protectionObj, blurbObj, cfg)
)
end
end
-- Render the categories
if yesno(args.category) ~= false then
ret[#ret + 1] = protectionObj:makeCategoryLinks()
end
return table.concat(ret)
end
function p.main(frame, cfg)
cfg = cfg or require(CONFIG_MODULE)
-- Find default args, if any.
local parent = frame.getParent and frame:getParent()
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')]
-- Find user args, and use the parent frame if we are being called from a
-- wrapper template.
getArgs = getArgs or require('Module:Arguments').getArgs
local userArgs = getArgs(frame, {
parentOnly = defaultArgs,
frameOnly = not defaultArgs
})
-- Build the args table. User-specified args overwrite default args.
local args = {}
for k, v in pairs(defaultArgs or {}) do
args[k] = v
end
for k, v in pairs(userArgs) do
args[k] = v
end
return p._main(args, cfg)
end
return p
894f0884d4c2da1ce19d385b96f59af654b0946a
Module:Protection banner/config
828
41
86
85
2023-10-01T08:21:11Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module provides configuration data for [[Module:Protection banner]].
return {
--------------------------------------------------------------------------------
--
-- BANNER DATA
--
--------------------------------------------------------------------------------
--[[
-- Banner data consists of six fields:
-- * text - the main protection text that appears at the top of protection
-- banners.
-- * explanation - the text that appears below the main protection text, used
-- to explain the details of the protection.
-- * tooltip - the tooltip text you see when you move the mouse over a small
-- padlock icon.
-- * link - the page that the small padlock icon links to.
-- * alt - the alt text for the small padlock icon. This is also used as tooltip
-- text for the large protection banners.
-- * image - the padlock image used in both protection banners and small padlock
-- icons.
--
-- The module checks in three separate tables to find a value for each field.
-- First it checks the banners table, which has values specific to the reason
-- for the page being protected. Then the module checks the defaultBanners
-- table, which has values specific to each protection level. Finally, the
-- module checks the masterBanner table, which holds data for protection
-- templates to use if no data has been found in the previous two tables.
--
-- The values in the banner data can take parameters. These are specified
-- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name
-- enclosed in curly braces).
--
-- Available parameters:
--
-- ${CURRENTVERSION} - a link to the page history or the move log, with the
-- display message "current-version-edit-display" or
-- "current-version-move-display".
--
-- ${EDITREQUEST} - a link to create an edit request for the current page.
--
-- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes
-- on the talk page; you may submit a request to ask an administrator to make
-- an edit if it is minor or supported by consensus."
--
-- ${IMAGELINK} - a link to set the image to, depending on the protection
-- action and protection level.
--
-- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry
-- is set. E.g. "Editing of this page by new or unregistered users is currently
-- disabled until dd Month YYYY."
--
-- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation
-- so that it can be used in run-on sentences.
--
-- ${PAGETYPE} - the type of the page, e.g. "article" or "template".
-- Defined in the cfg.pagetypes table.
--
-- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g.
-- "Editing of this page by new or unregistered users is currently disabled"
--
-- ${PROTECTIONDATE} - the protection date, if it has been supplied to the
-- template.
--
-- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or
-- "semi-protected".
--
-- ${PROTECTIONLOG} - a link to the protection log or the pending changes log,
-- depending on the protection action.
--
-- ${TALKPAGE} - a link to the talk page. If a section is specified, links
-- straight to that talk page section.
--
-- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to
-- create a blurb like "This template is semi-protected", or "This article is
-- move-protected until DD Month YYYY".
--
-- ${VANDAL} - links for the specified username (or the root page name)
-- using Module:Vandal-m.
--
-- Functions
--
-- For advanced users, it is possible to use Lua functions instead of strings
-- in the banner config tables. Using functions gives flexibility that is not
-- possible just by using parameters. Functions take two arguments, the
-- protection object and the template arguments, and they must output a string.
--
-- For example:
--
-- text = function (protectionObj, args)
-- if protectionObj.level == 'autoconfirmed' then
-- return 'foo'
-- else
-- return 'bar'
-- end
-- end
--
-- Some protection object properties and methods that may be useful:
-- protectionObj.action - the protection action
-- protectionObj.level - the protection level
-- protectionObj.reason - the protection reason
-- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set
-- to indefinite, and the protection time in unix time if temporary.
-- protectionObj.protectionDate - the protection date in unix time, or nil if
-- unspecified.
-- protectionObj.bannerConfig - the banner config found by the module. Beware
-- of editing the config field used by the function, as it could create an
-- infinite loop.
-- protectionObj:isProtected - returns a boolean showing whether the page is
-- protected.
-- protectionObj:isTemporary - returns a boolean showing whether the expiry is
-- temporary.
-- protectionObj:isIncorrect - returns a boolean showing whether the protection
-- template is incorrect.
--]]
-- The master banner data, used if no values have been found in banners or
-- defaultBanners.
masterBanner = {
text = '${INTROBLURB}',
explanation = '${EXPLANATIONBLURB}',
tooltip = '${TOOLTIPBLURB}',
link = '${IMAGELINK}',
alt = 'Page ${PROTECTIONLEVEL}'
},
-- The default banner data. This holds banner data for different protection
-- levels.
-- *required* - this table needs edit, move, autoreview and upload subtables.
defaultBanners = {
edit = {},
move = {},
autoreview = {
default = {
alt = 'Page protected with pending changes',
tooltip = 'All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users',
image = 'Pending-protection-shackle.svg'
}
},
upload = {}
},
-- The banner data. This holds banner data for different protection reasons.
-- In fact, the reasons specified in this table control which reasons are
-- valid inputs to the first positional parameter.
--
-- There is also a non-standard "description" field that can be used for items
-- in this table. This is a description of the protection reason for use in the
-- module documentation.
--
-- *required* - this table needs edit, move, autoreview and upload subtables.
banners = {
edit = {
blp = {
description = 'For pages protected to promote compliance with the'
.. ' [[Wikipedia:Biographies of living persons'
.. '|biographies of living persons]] policy',
text = '${INTROFRAGMENT} to promote compliance with'
.. ' [[Wikipedia:Biographies of living persons'
.. "|Wikipedia's policy on the biographies"
.. ' of living people]].',
tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on'
.. ' biographies of living persons',
},
dmca = {
description = 'For pages protected by the Wikimedia Foundation'
.. ' due to [[Digital Millennium Copyright Act]] takedown requests',
explanation = function (protectionObj, args)
local ret = 'Pursuant to a rights owner notice under the Digital'
.. ' Millennium Copyright Act (DMCA) regarding some content'
.. ' in this article, the Wikimedia Foundation acted under'
.. ' applicable law and took down and restricted the content'
.. ' in question.'
if args.notice then
ret = ret .. ' A copy of the received notice can be found here: '
.. args.notice .. '.'
end
ret = ret .. ' For more information, including websites discussing'
.. ' how to file a counter-notice, please see'
.. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}."
.. "'''Do not remove this template from the article until the"
.. " restrictions are withdrawn'''."
return ret
end,
image = 'Office-protection-shackle.svg',
},
dispute = {
description = 'For pages protected due to editing disputes',
text = function (protectionObj, args)
-- Find the value of "disputes".
local display = 'disputes'
local disputes
if args.section then
disputes = string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[protectionObj.title.namespace].talk.name,
protectionObj.title.text,
args.section,
display
)
else
disputes = display
end
-- Make the blurb, depending on the expiry.
local msg
if type(protectionObj.expiry) == 'number' then
msg = '${INTROFRAGMENT} or until editing %s have been resolved.'
else
msg = '${INTROFRAGMENT} until editing %s have been resolved.'
end
return string.format(msg, disputes)
end,
explanation = "This protection is '''not''' an endorsement of the"
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',
tooltip = '${TOOLTIPFRAGMENT} due to editing disputes',
},
ecp = {
description = 'For articles in topic areas authorized by'
.. ' [[Wikipedia:Arbitration Committee|ArbCom]] or'
.. ' meets the criteria for community use',
tooltip = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',
alt = 'Extended-protected ${PAGETYPE}',
},
mainpage = {
description = 'For pages protected for being displayed on the [[Main Page]]',
text = 'This file is currently'
.. ' [[Wikipedia:This page is protected|protected]] from'
.. ' editing because it is currently or will soon be displayed'
.. ' on the [[Main Page]].',
explanation = 'Images on the Main Page are protected due to their high'
.. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.'
.. '<br /><span style="font-size:90%;">'
.. "'''Administrators:''' Once this image is definitely off the Main Page,"
.. ' please unprotect this file, or reduce to semi-protection,'
.. ' as appropriate.</span>',
},
office = {
description = 'For pages protected by the Wikimedia Foundation',
text = function (protectionObj, args)
local ret = 'This ${PAGETYPE} is currently under the'
.. ' scrutiny of the'
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'
.. ' and is protected.'
if protectionObj.protectionDate then
ret = ret .. ' It has been protected since ${PROTECTIONDATE}.'
end
return ret
end,
explanation = "If you can edit this page, please discuss all changes and"
.. " additions on the ${TALKPAGE} first. '''Do not remove protection from this"
.. " page unless you are authorized by the Wikimedia Foundation to do"
.. " so.'''",
image = 'Office-protection-shackle.svg',
},
reset = {
description = 'For pages protected by the Wikimedia Foundation and'
.. ' "reset" to a bare-bones version',
text = 'This ${PAGETYPE} is currently under the'
.. ' scrutiny of the'
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'
.. ' and is protected.',
explanation = function (protectionObj, args)
local ret = ''
if protectionObj.protectionDate then
ret = ret .. 'On ${PROTECTIONDATE} this ${PAGETYPE} was'
else
ret = ret .. 'This ${PAGETYPE} has been'
end
ret = ret .. ' reduced to a'
.. ' simplified, "bare bones" version so that it may be completely'
.. ' rewritten to ensure it meets the policies of'
.. ' [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].'
.. ' Standard Wikipedia policies will apply to its rewriting—which'
.. ' will eventually be open to all editors—and will be strictly'
.. ' enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while'
.. ' it is being rebuilt.\n\n'
.. 'Any insertion of material directly from'
.. ' pre-protection revisions of the ${PAGETYPE} will be removed, as'
.. ' will any material added to the ${PAGETYPE} that is not properly'
.. ' sourced. The associated talk page(s) were also cleared on the'
.. " same date.\n\n"
.. "If you can edit this page, please discuss all changes and"
.. " additions on the ${TALKPAGE} first. '''Do not override"
.. " this action, and do not remove protection from this page,"
.. " unless you are authorized by the Wikimedia Foundation"
.. " to do so. No editor may remove this notice.'''"
return ret
end,
image = 'Office-protection-shackle.svg',
},
sock = {
description = 'For pages protected due to'
.. ' [[Wikipedia:Sock puppetry|sock puppetry]]',
text = '${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of'
.. ' [[Wikipedia:Blocking policy|blocked]] or'
.. ' [[Wikipedia:Banning policy|banned users]]'
.. ' from editing it.',
tooltip = '${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from'
.. ' editing it',
},
template = {
description = 'For [[Wikipedia:High-risk templates|high-risk]]'
.. ' templates and Lua modules',
text = 'This is a permanently [[Help:Protection|protected]] ${PAGETYPE},'
.. ' as it is [[Wikipedia:High-risk templates|high-risk]].',
explanation = 'Please discuss any changes on the ${TALKPAGE}; you may'
.. ' ${EDITREQUEST} to ask an'
.. ' [[Wikipedia:Administrators|administrator]] or'
.. ' [[Wikipedia:Template editor|template editor]] to make an edit if'
.. ' it is [[Help:Minor edit#When to mark an edit as a minor edit'
.. '|uncontroversial]] or supported by'
.. ' [[Wikipedia:Consensus|consensus]]. You can also'
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'
.. ' unprotected.',
tooltip = 'This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}'
.. ' to prevent vandalism',
alt = 'Permanently protected ${PAGETYPE}',
},
usertalk = {
description = 'For pages protected against disruptive edits by a'
.. ' particular user',
text = '${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,'
.. ' such as abusing the'
.. ' {{[[Template:unblock|unblock]]}} template.',
explanation = 'If you cannot edit this user talk page and you need to'
.. ' make a change or leave a message, you can'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for edits to a protected page'
.. '|request an edit]],'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for reduction in protection level'
.. '|request unprotection]],'
.. ' [[Special:Userlogin|log in]],'
.. ' or [[Special:UserLogin/signup|create an account]].',
},
vandalism = {
description = 'For pages protected against'
.. ' [[Wikipedia:Vandalism|vandalism]]',
text = '${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].',
explanation = function (protectionObj, args)
local ret = ''
if protectionObj.level == 'sysop' then
ret = ret .. "This protection is '''not''' an endorsement of the"
.. ' ${CURRENTVERSION}. '
end
return ret .. '${EXPLANATIONBLURB}'
end,
tooltip = '${TOOLTIPFRAGMENT} due to vandalism',
}
},
move = {
dispute = {
description = 'For pages protected against page moves due to'
.. ' disputes over the page title',
explanation = "This protection is '''not''' an endorsement of the"
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',
image = 'Move-protection-shackle.svg'
},
vandalism = {
description = 'For pages protected against'
.. ' [[Wikipedia:Vandalism#Page-move vandalism'
.. ' |page-move vandalism]]'
}
},
autoreview = {},
upload = {}
},
--------------------------------------------------------------------------------
--
-- GENERAL DATA TABLES
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Protection blurbs
--------------------------------------------------------------------------------
-- This table produces the protection blurbs available with the
-- ${PROTECTIONBLURB} parameter. It is sorted by protection action and
-- protection level, and is checked by the module in the following order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
-- 3. "edit" protection action, default protection level
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, autoreview and upload subtables.
protectionBlurbs = {
edit = {
default = 'This ${PAGETYPE} is currently [[Help:Protection|'
.. 'protected]] from editing',
autoconfirmed = 'Editing of this ${PAGETYPE} by [[Wikipedia:User access'
.. ' levels#New users|new]] or [[Wikipedia:User access levels#Unregistered'
.. ' users|unregistered]] users is currently [[Help:Protection|disabled]]',
extendedconfirmed = 'This ${PAGETYPE} is currently under extended confirmed protection',
},
move = {
default = 'This ${PAGETYPE} is currently [[Help:Protection|protected]]'
.. ' from [[Help:Moving a page|page moves]]'
},
autoreview = {
default = 'All edits made to this ${PAGETYPE} by'
.. ' [[Wikipedia:User access levels#New users|new]] or'
.. ' [[Wikipedia:User access levels#Unregistered users|unregistered]]'
.. ' users are currently'
.. ' [[Wikipedia:Pending changes|subject to review]]'
},
upload = {
default = 'Uploading new versions of this ${PAGETYPE} is currently disabled'
}
},
--------------------------------------------------------------------------------
-- Explanation blurbs
--------------------------------------------------------------------------------
-- This table produces the explanation blurbs available with the
-- ${EXPLANATIONBLURB} parameter. It is sorted by protection action,
-- protection level, and whether the page is a talk page or not. If the page is
-- a talk page it will have a talk key of "talk"; otherwise it will have a talk
-- key of "subject". The table is checked in the following order:
-- 1. page's protection action, page's protection level, page's talk key
-- 2. page's protection action, page's protection level, default talk key
-- 3. page's protection action, default protection level, page's talk key
-- 4. page's protection action, default protection level, default talk key
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, autoreview and upload subtables.
explanationBlurbs = {
edit = {
autoconfirmed = {
subject = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'
.. ' ${EDITREQUEST}, discuss changes on the ${TALKPAGE},'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for reduction in protection level'
.. '|request unprotection]], [[Special:Userlogin|log in]], or'
.. ' [[Special:UserLogin/signup|create an account]].',
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for reduction in protection level'
.. '|request unprotection]], [[Special:Userlogin|log in]], or'
.. ' [[Special:UserLogin/signup|create an account]].',
},
extendedconfirmed = {
default = 'Extended confirmed protection prevents edits from all unregistered editors'
.. ' and registered users with fewer than 30 days tenure and 500 edits.'
.. ' The [[Wikipedia:Protection policy#extended|policy on community use]]'
.. ' specifies that extended confirmed protection can be applied to combat'
.. ' disruption, if semi-protection has proven to be ineffective.'
.. ' Extended confirmed protection may also be applied to enforce'
.. ' [[Wikipedia:Arbitration Committee|arbitration sanctions]].'
.. ' Please discuss any changes on the ${TALKPAGE}; you may'
.. ' ${EDITREQUEST} to ask for uncontroversial changes supported by'
.. ' [[Wikipedia:Consensus|consensus]].'
},
default = {
subject = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' Please discuss any changes on the ${TALKPAGE}; you'
.. ' may ${EDITREQUEST} to ask an'
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'
.. '|consensus]]. You may also [[Wikipedia:Requests for'
.. ' page protection#Current requests for reduction in protection level'
.. '|request]] that this page be unprotected.',
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' You may [[Wikipedia:Requests for page'
.. ' protection#Current requests for edits to a protected page|request an'
.. ' edit]] to this page, or [[Wikipedia:Requests for'
.. ' page protection#Current requests for reduction in protection level'
.. '|ask]] for it to be unprotected.'
}
},
move = {
default = {
subject = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' The page may still be edited but cannot be moved'
.. ' until unprotected. Please discuss any suggested moves on the'
.. ' ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also'
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'
.. ' unprotected.',
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' The page may still be edited but cannot be moved'
.. ' until unprotected. Please discuss any suggested moves at'
.. ' [[Wikipedia:Requested moves]]. You can also'
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'
.. ' unprotected.'
}
},
autoreview = {
default = {
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' Edits to this ${PAGETYPE} by new and unregistered users'
.. ' will not be visible to readers until they are accepted by'
.. ' a reviewer. To avoid the need for your edits to be'
.. ' reviewed, you may'
.. ' [[Wikipedia:Requests for page protection'
.. '#Current requests for reduction in protection level'
.. '|request unprotection]], [[Special:Userlogin|log in]], or'
.. ' [[Special:UserLogin/signup|create an account]].'
},
},
upload = {
default = {
default = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' The page may still be edited but new versions of the file'
.. ' cannot be uploaded until it is unprotected. You can'
.. ' request that a new version be uploaded by using a'
.. ' [[Wikipedia:Edit requests|protected edit request]], or you'
.. ' can [[Wikipedia:Requests for page protection|request]]'
.. ' that the file be unprotected.'
}
}
},
--------------------------------------------------------------------------------
-- Protection levels
--------------------------------------------------------------------------------
-- This table provides the data for the ${PROTECTIONLEVEL} parameter, which
-- produces a short label for different protection levels. It is sorted by
-- protection action and protection level, and is checked in the following
-- order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
-- 3. "edit" protection action, default protection level
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, autoreview and upload subtables.
protectionLevels = {
edit = {
default = 'protected',
templateeditor = 'template-protected',
extendedconfirmed = 'extended-protected',
autoconfirmed = 'semi-protected',
},
move = {
default = 'move-protected'
},
autoreview = {
},
upload = {
default = 'upload-protected'
}
},
--------------------------------------------------------------------------------
-- Images
--------------------------------------------------------------------------------
-- This table lists different padlock images for each protection action and
-- protection level. It is used if an image is not specified in any of the
-- banner data tables, and if the page does not satisfy the conditions for using
-- the ['image-filename-indef'] image. It is checked in the following order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
images = {
edit = {
default = 'Full-protection-shackle.svg',
templateeditor = 'Template-protection-shackle.svg',
extendedconfirmed = 'Extended-protection-shackle.svg',
autoconfirmed = 'Semi-protection-shackle.svg'
},
move = {
default = 'Move-protection-shackle.svg',
},
autoreview = {
default = 'Pending-protection-shackle.svg'
},
upload = {
default = 'Upload-protection-shackle.svg'
}
},
-- Pages with a reason specified in this table will show the special "indef"
-- padlock, defined in the 'image-filename-indef' message, if no expiry is set.
indefImageReasons = {
template = true
},
--------------------------------------------------------------------------------
-- Image links
--------------------------------------------------------------------------------
-- This table provides the data for the ${IMAGELINK} parameter, which gets
-- the image link for small padlock icons based on the page's protection action
-- and protection level. It is checked in the following order:
-- 1. page's protection action, page's protection level
-- 2. page's protection action, default protection level
-- 3. "edit" protection action, default protection level
--
-- It is possible to use banner parameters inside this table.
-- *required* - this table needs edit, move, autoreview and upload subtables.
imageLinks = {
edit = {
default = 'Wikipedia:Protection policy#full',
templateeditor = 'Wikipedia:Protection policy#template',
extendedconfirmed = 'Wikipedia:Protection policy#extended',
autoconfirmed = 'Wikipedia:Protection policy#semi'
},
move = {
default = 'Wikipedia:Protection policy#move'
},
autoreview = {
default = 'Wikipedia:Protection policy#pending'
},
upload = {
default = 'Wikipedia:Protection policy#upload'
}
},
--------------------------------------------------------------------------------
-- Padlock indicator names
--------------------------------------------------------------------------------
-- This table provides the "name" attribute for the <indicator> extension tag
-- with which small padlock icons are generated. All indicator tags on a page
-- are displayed in alphabetical order based on this attribute, and with
-- indicator tags with duplicate names, the last tag on the page wins.
-- The attribute is chosen based on the protection action; table keys must be a
-- protection action name or the string "default".
padlockIndicatorNames = {
autoreview = 'pp-autoreview',
default = 'pp-default'
},
--------------------------------------------------------------------------------
-- Protection categories
--------------------------------------------------------------------------------
--[[
-- The protection categories are stored in the protectionCategories table.
-- Keys to this table are made up of the following strings:
--
-- 1. the expiry date
-- 2. the namespace
-- 3. the protection reason (e.g. "dispute" or "vandalism")
-- 4. the protection level (e.g. "sysop" or "autoconfirmed")
-- 5. the action (e.g. "edit" or "move")
--
-- When the module looks up a category in the table, first it will will check to
-- see a key exists that corresponds to all five parameters. For example, a
-- user page semi-protected from vandalism for two weeks would have the key
-- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module
-- changes the first part of the key to "all" and checks the table again. It
-- keeps checking increasingly generic key combinations until it finds the
-- field, or until it reaches the key "all-all-all-all-all".
--
-- The module uses a binary matrix to determine the order in which to search.
-- This is best demonstrated by a table. In this table, the "0" values
-- represent "all", and the "1" values represent the original data (e.g.
-- "indef" or "file" or "vandalism").
--
-- expiry namespace reason level action
-- order
-- 1 1 1 1 1 1
-- 2 0 1 1 1 1
-- 3 1 0 1 1 1
-- 4 0 0 1 1 1
-- 5 1 1 0 1 1
-- 6 0 1 0 1 1
-- 7 1 0 0 1 1
-- 8 0 0 0 1 1
-- 9 1 1 1 0 1
-- 10 0 1 1 0 1
-- 11 1 0 1 0 1
-- 12 0 0 1 0 1
-- 13 1 1 0 0 1
-- 14 0 1 0 0 1
-- 15 1 0 0 0 1
-- 16 0 0 0 0 1
-- 17 1 1 1 1 0
-- 18 0 1 1 1 0
-- 19 1 0 1 1 0
-- 20 0 0 1 1 0
-- 21 1 1 0 1 0
-- 22 0 1 0 1 0
-- 23 1 0 0 1 0
-- 24 0 0 0 1 0
-- 25 1 1 1 0 0
-- 26 0 1 1 0 0
-- 27 1 0 1 0 0
-- 28 0 0 1 0 0
-- 29 1 1 0 0 0
-- 30 0 1 0 0 0
-- 31 1 0 0 0 0
-- 32 0 0 0 0 0
--
-- In this scheme the action has the highest priority, as it is the last
-- to change, and the expiry has the least priority, as it changes the most.
-- The priorities of the expiry, the protection level and the action are
-- fixed, but the priorities of the reason and the namespace can be swapped
-- through the use of the cfg.bannerDataNamespaceHasPriority table.
--]]
-- If the reason specified to the template is listed in this table,
-- namespace data will take priority over reason data in the protectionCategories
-- table.
reasonsWithNamespacePriority = {
vandalism = true,
},
-- The string to use as a namespace key for the protectionCategories table for each
-- namespace number.
categoryNamespaceKeys = {
[ 2] = 'user',
[ 3] = 'user',
[ 4] = 'project',
[ 6] = 'file',
[ 8] = 'mediawiki',
[ 10] = 'template',
[ 12] = 'project',
[ 14] = 'category',
[100] = 'portal',
[828] = 'module',
},
protectionCategories = {
['all|all|all|all|all'] = 'Wikipedia fully protected pages',
['all|all|office|all|all'] = 'Wikipedia Office-protected pages',
['all|all|reset|all|all'] = 'Wikipedia Office-protected pages',
['all|all|dmca|all|all'] = 'Wikipedia Office-protected pages',
['all|all|mainpage|all|all'] = 'Wikipedia fully protected main page files',
['all|all|all|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',
['all|all|ecp|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',
['all|template|all|all|edit'] = 'Wikipedia fully protected templates',
['all|all|all|autoconfirmed|edit'] = 'Wikipedia semi-protected pages',
['indef|all|all|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected pages',
['all|all|blp|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected biographies of living people',
['temp|all|blp|autoconfirmed|edit'] = 'Wikipedia temporarily semi-protected biographies of living people',
['all|all|dispute|autoconfirmed|edit'] = 'Wikipedia pages semi-protected due to dispute',
['all|all|sock|autoconfirmed|edit'] = 'Wikipedia pages semi-protected from banned users',
['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism',
['all|category|all|autoconfirmed|edit'] = 'Wikipedia semi-protected categories',
['all|file|all|autoconfirmed|edit'] = 'Wikipedia semi-protected files',
['all|portal|all|autoconfirmed|edit'] = 'Wikipedia semi-protected portals',
['all|project|all|autoconfirmed|edit'] = 'Wikipedia semi-protected project pages',
['all|talk|all|autoconfirmed|edit'] = 'Wikipedia semi-protected talk pages',
['all|template|all|autoconfirmed|edit'] = 'Wikipedia semi-protected templates',
['all|user|all|autoconfirmed|edit'] = 'Wikipedia semi-protected user and user talk pages',
['all|all|all|templateeditor|edit'] = 'Wikipedia template-protected pages other than templates and modules',
['all|template|all|templateeditor|edit'] = 'Wikipedia template-protected templates',
['all|template|all|templateeditor|move'] = 'Wikipedia template-protected templates', -- move-protected templates
['all|all|blp|sysop|edit'] = 'Wikipedia indefinitely protected biographies of living people',
['temp|all|blp|sysop|edit'] = 'Wikipedia temporarily protected biographies of living people',
['all|all|dispute|sysop|edit'] = 'Wikipedia pages protected due to dispute',
['all|all|sock|sysop|edit'] = 'Wikipedia pages protected from banned users',
['all|all|vandalism|sysop|edit'] = 'Wikipedia pages protected against vandalism',
['all|category|all|sysop|edit'] = 'Wikipedia fully protected categories',
['all|file|all|sysop|edit'] = 'Wikipedia fully protected files',
['all|project|all|sysop|edit'] = 'Wikipedia fully protected project pages',
['all|talk|all|sysop|edit'] = 'Wikipedia fully protected talk pages',
['all|template|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected templates',
['all|template|all|sysop|edit'] = 'Wikipedia fully protected templates',
['all|user|all|sysop|edit'] = 'Wikipedia fully protected user and user talk pages',
['all|module|all|all|edit'] = 'Wikipedia fully protected modules',
['all|module|all|templateeditor|edit'] = 'Wikipedia template-protected modules',
['all|module|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected modules',
['all|module|all|autoconfirmed|edit'] = 'Wikipedia semi-protected modules',
['all|all|all|sysop|move'] = 'Wikipedia move-protected pages',
['indef|all|all|sysop|move'] = 'Wikipedia indefinitely move-protected pages',
['all|all|dispute|sysop|move'] = 'Wikipedia pages move-protected due to dispute',
['all|all|vandalism|sysop|move'] = 'Wikipedia pages move-protected due to vandalism',
['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals',
['all|project|all|sysop|move'] = 'Wikipedia move-protected project pages',
['all|talk|all|sysop|move'] = 'Wikipedia move-protected talk pages',
['all|template|all|sysop|move'] = 'Wikipedia move-protected templates',
['all|user|all|sysop|move'] = 'Wikipedia move-protected user and user talk pages',
['all|all|all|autoconfirmed|autoreview'] = 'Wikipedia pending changes protected pages',
['all|file|all|all|upload'] = 'Wikipedia upload-protected files',
},
--------------------------------------------------------------------------------
-- Expiry category config
--------------------------------------------------------------------------------
-- This table configures the expiry category behaviour for each protection
-- action.
-- * If set to true, setting that action will always categorise the page if
-- an expiry parameter is not set.
-- * If set to false, setting that action will never categorise the page.
-- * If set to nil, the module will categorise the page if:
-- 1) an expiry parameter is not set, and
-- 2) a reason is provided, and
-- 3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck
-- table.
expiryCheckActions = {
edit = nil,
move = false,
autoreview = true,
upload = false
},
reasonsWithoutExpiryCheck = {
blp = true,
template = true,
},
--------------------------------------------------------------------------------
-- Pagetypes
--------------------------------------------------------------------------------
-- This table produces the page types available with the ${PAGETYPE} parameter.
-- Keys are namespace numbers, or the string "default" for the default value.
pagetypes = {
[0] = 'article',
[6] = 'file',
[10] = 'template',
[14] = 'category',
[828] = 'module',
default = 'page'
},
--------------------------------------------------------------------------------
-- Strings marking indefinite protection
--------------------------------------------------------------------------------
-- This table contains values passed to the expiry parameter that mean the page
-- is protected indefinitely.
indefStrings = {
['indef'] = true,
['indefinite'] = true,
['indefinitely'] = true,
['infinite'] = true,
},
--------------------------------------------------------------------------------
-- Group hierarchy
--------------------------------------------------------------------------------
-- This table maps each group to all groups that have a superset of the original
-- group's page editing permissions.
hierarchy = {
sysop = {},
reviewer = {'sysop'},
filemover = {'sysop'},
templateeditor = {'sysop'},
extendedconfirmed = {'sysop'},
autoconfirmed = {'reviewer', 'filemover', 'templateeditor', 'extendedconfirmed'},
user = {'autoconfirmed'},
['*'] = {'user'}
},
--------------------------------------------------------------------------------
-- Wrapper templates and their default arguments
--------------------------------------------------------------------------------
-- This table contains wrapper templates used with the module, and their
-- default arguments. Templates specified in this table should contain the
-- following invocation, and no other template content:
--
-- {{#invoke:Protection banner|main}}
--
-- If other content is desired, it can be added between
-- <noinclude>...</noinclude> tags.
--
-- When a user calls one of these wrapper templates, they will use the
-- default arguments automatically. However, users can override any of the
-- arguments.
wrappers = {
['Template:Pp'] = {},
['Template:Pp-extended'] = {'ecp'},
['Template:Pp-blp'] = {'blp'},
-- we don't need Template:Pp-create
['Template:Pp-dispute'] = {'dispute'},
['Template:Pp-main-page'] = {'mainpage'},
['Template:Pp-move'] = {action = 'move', catonly = 'yes'},
['Template:Pp-move-dispute'] = {'dispute', action = 'move', catonly = 'yes'},
-- we don't need Template:Pp-move-indef
['Template:Pp-move-vandalism'] = {'vandalism', action = 'move', catonly = 'yes'},
['Template:Pp-office'] = {'office'},
['Template:Pp-office-dmca'] = {'dmca'},
['Template:Pp-pc'] = {action = 'autoreview', small = true},
['Template:Pp-pc1'] = {action = 'autoreview', small = true},
['Template:Pp-reset'] = {'reset'},
['Template:Pp-semi-indef'] = {small = true},
['Template:Pp-sock'] = {'sock'},
['Template:Pp-template'] = {'template', small = true},
['Template:Pp-upload'] = {action = 'upload'},
['Template:Pp-usertalk'] = {'usertalk'},
['Template:Pp-vandalism'] = {'vandalism'},
},
--------------------------------------------------------------------------------
--
-- MESSAGES
--
--------------------------------------------------------------------------------
msg = {
--------------------------------------------------------------------------------
-- Intro blurb and intro fragment
--------------------------------------------------------------------------------
-- These messages specify what is produced by the ${INTROBLURB} and
-- ${INTROFRAGMENT} parameters. If the protection is temporary they use the
-- intro-blurb-expiry or intro-fragment-expiry, and if not they use
-- intro-blurb-noexpiry or intro-fragment-noexpiry.
-- It is possible to use banner parameters in these messages.
['intro-blurb-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY}.',
['intro-blurb-noexpiry'] = '${PROTECTIONBLURB}.',
['intro-fragment-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY},',
['intro-fragment-noexpiry'] = '${PROTECTIONBLURB}',
--------------------------------------------------------------------------------
-- Tooltip blurb
--------------------------------------------------------------------------------
-- These messages specify what is produced by the ${TOOLTIPBLURB} parameter.
-- If the protection is temporary the tooltip-blurb-expiry message is used, and
-- if not the tooltip-blurb-noexpiry message is used.
-- It is possible to use banner parameters in these messages.
['tooltip-blurb-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.',
['tooltip-blurb-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}.',
['tooltip-fragment-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},',
['tooltip-fragment-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',
--------------------------------------------------------------------------------
-- Special explanation blurb
--------------------------------------------------------------------------------
-- An explanation blurb for pages that cannot be unprotected, e.g. for pages
-- in the MediaWiki namespace.
-- It is possible to use banner parameters in this message.
['explanation-blurb-nounprotect'] = 'See the [[Wikipedia:Protection policy|'
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'
.. ' Please discuss any changes on the ${TALKPAGE}; you'
.. ' may ${EDITREQUEST} to ask an'
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'
.. '|consensus]].',
--------------------------------------------------------------------------------
-- Protection log display values
--------------------------------------------------------------------------------
-- These messages determine the display values for the protection log link
-- or the pending changes log link produced by the ${PROTECTIONLOG} parameter.
-- It is possible to use banner parameters in these messages.
['protection-log-display'] = 'protection log',
['pc-log-display'] = 'pending changes log',
--------------------------------------------------------------------------------
-- Current version display values
--------------------------------------------------------------------------------
-- These messages determine the display values for the page history link
-- or the move log link produced by the ${CURRENTVERSION} parameter.
-- It is possible to use banner parameters in these messages.
['current-version-move-display'] = 'current title',
['current-version-edit-display'] = 'current version',
--------------------------------------------------------------------------------
-- Talk page
--------------------------------------------------------------------------------
-- This message determines the display value of the talk page link produced
-- with the ${TALKPAGE} parameter.
-- It is possible to use banner parameters in this message.
['talk-page-link-display'] = 'talk page',
--------------------------------------------------------------------------------
-- Edit requests
--------------------------------------------------------------------------------
-- This message determines the display value of the edit request link produced
-- with the ${EDITREQUEST} parameter.
-- It is possible to use banner parameters in this message.
['edit-request-display'] = 'submit an edit request',
--------------------------------------------------------------------------------
-- Expiry date format
--------------------------------------------------------------------------------
-- This is the format for the blurb expiry date. It should be valid input for
-- the first parameter of the #time parser function.
['expiry-date-format'] = 'F j, Y "at" H:i e',
--------------------------------------------------------------------------------
-- Tracking categories
--------------------------------------------------------------------------------
-- These messages determine which tracking categories the module outputs.
['tracking-category-incorrect'] = 'Wikipedia pages with incorrect protection templates',
['tracking-category-template'] = 'Wikipedia template-protected pages other than templates and modules',
--------------------------------------------------------------------------------
-- Images
--------------------------------------------------------------------------------
-- These are images that are not defined by their protection action and protection level.
['image-filename-indef'] = 'Full-protection-shackle.svg',
['image-filename-default'] = 'Transparent.gif',
--------------------------------------------------------------------------------
-- End messages
--------------------------------------------------------------------------------
}
--------------------------------------------------------------------------------
-- End configuration
--------------------------------------------------------------------------------
}
a20552ae38cb5253a4fa29aa126abc74215a589f
Module:Sidebar
828
42
88
87
2023-10-01T08:21:11Z
Reverie
2
1 revision imported
Scribunto
text/plain
require('strict')
local cfg = mw.loadData('Module:Sidebar/configuration')
local p = {}
local getArgs = require('Module:Arguments').getArgs
--[[
Categorizes calling templates and modules with a 'style' parameter of any sort
for tracking to convert to TemplateStyles.
TODO after a long cleanup: Catch sidebars in other namespaces than Template and Module.
TODO would probably want to remove /log and /archive as CS1 does
]]
local function categorizeTemplatesWithInlineStyles(args)
local title = mw.title.getCurrentTitle()
if title.namespace ~= 10 and title.namespace ~= 828 then return '' end
for _, pattern in ipairs (cfg.i18n.pattern.uncategorized_conversion_titles) do
if title.text:match(pattern) then return '' end
end
for key, _ in pairs(args) do
if mw.ustring.find(key, cfg.i18n.pattern.style_conversion) or key == 'width' then
return cfg.i18n.category.conversion
end
end
end
--[[
For compatibility with the original {{sidebar with collapsible lists}}
implementation, which passed some parameters through {{#if}} to trim their
whitespace. This also triggered the automatic newline behavior.
]]
-- See ([[meta:Help:Newlines and spaces#Automatic newline]])
local function trimAndAddAutomaticNewline(s)
s = mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1")
if mw.ustring.find(s, '^[#*:;]') or mw.ustring.find(s, '^{|') then
return '\n' .. s
else
return s
end
end
--[[
Finds whether a sidebar has a subgroup sidebar.
]]
local function hasSubgroup(s)
if mw.ustring.find(s, cfg.i18n.pattern.subgroup) then
return true
else
return false
end
end
local function has_navbar(navbar_mode, sidebar_name)
return navbar_mode ~= cfg.i18n.navbar_none and
navbar_mode ~= cfg.i18n.navbar_off and
(
sidebar_name or
mw.getCurrentFrame():getParent():getTitle():gsub(cfg.i18n.pattern.sandbox, '') ~=
cfg.i18n.title_not_to_add_navbar
)
end
local function has_list_class(args, htmlclass)
local patterns = {
'^' .. htmlclass .. '$',
'%s' .. htmlclass .. '$',
'^' .. htmlclass .. '%s',
'%s' .. htmlclass .. '%s'
}
for arg, value in pairs(args) do
if type(arg) == 'string' and mw.ustring.find(arg, 'class') then
for _, pattern in ipairs(patterns) do
if mw.ustring.find(args[arg] or '', pattern) then
return true
end
end
end
end
return false
end
-- there are a lot of list classes in the wild, so we add their TemplateStyles
local function add_list_styles(args)
local frame = mw.getCurrentFrame()
local function add_list_templatestyles(htmlclass, templatestyles)
if has_list_class(args, htmlclass) then
return frame:extensionTag{
name = 'templatestyles', args = { src = templatestyles }
}
else
return ''
end
end
local plainlist_styles = add_list_templatestyles('plainlist', cfg.i18n.plainlist_templatestyles)
local hlist_styles = add_list_templatestyles('hlist', cfg.i18n.hlist_templatestyles)
-- a second workaround for [[phab:T303378]]
-- when that issue is fixed, we can actually use has_navbar not to emit the
-- tag here if we want
if has_navbar(args.navbar, args.name) and hlist_styles == '' then
hlist_styles = frame:extensionTag{
name = 'templatestyles', args = { src = cfg.i18n.hlist_templatestyles}
}
end
-- hlist -> plainlist is best-effort to preserve old Common.css ordering. [hlist_note]
return hlist_styles .. plainlist_styles
end
-- work around [[phab:T303378]]
-- for each arg: find all the templatestyles strip markers, insert them into a
-- table. then remove all templatestyles markers from the arg
local function move_hiding_templatestyles(args)
local gfind = string.gfind
local gsub = string.gsub
local templatestyles_markers = {}
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
for k, arg in pairs(args) do
for marker in gfind(arg, strip_marker_pattern) do
table.insert(templatestyles_markers, marker)
end
args[k] = gsub(arg, strip_marker_pattern, '')
end
return templatestyles_markers
end
--[[
Main sidebar function. Takes the frame, args, and an optional collapsibleClass.
The collapsibleClass is and should be used only for sidebars with collapsible
lists, as in p.collapsible.
]]
function p.sidebar(frame, args, collapsibleClass)
if not args then
args = getArgs(frame)
end
local hiding_templatestyles = table.concat(move_hiding_templatestyles(args))
local root = mw.html.create()
local child = args.child and mw.text.trim(args.child) == cfg.i18n.child_yes
root = root:tag('table')
if not child then
root
:addClass(cfg.i18n.class.sidebar)
-- force collapsibleclass to be sidebar-collapse otherwise output nothing
:addClass(collapsibleClass == cfg.i18n.class.collapse and cfg.i18n.class.collapse or nil)
:addClass('nomobile')
:addClass(args.float == cfg.i18n.float_none and cfg.i18n.class.float_none or nil)
:addClass(args.float == cfg.i18n.float_left and cfg.i18n.class.float_left or nil)
:addClass(args.wraplinks ~= cfg.i18n.wrap_true and cfg.i18n.class.wraplinks or nil)
:addClass(args.bodyclass or args.class)
:css('width', args.width or nil)
:cssText(args.bodystyle or args.style)
if args.outertitle then
root
:tag('caption')
:addClass(cfg.i18n.class.outer_title)
:addClass(args.outertitleclass)
:cssText(args.outertitlestyle)
:wikitext(args.outertitle)
end
if args.topimage then
local imageCell = root:tag('tr'):tag('td')
imageCell
:addClass(cfg.i18n.class.top_image)
:addClass(args.topimageclass)
:cssText(args.topimagestyle)
:wikitext(args.topimage)
if args.topcaption then
imageCell
:tag('div')
:addClass(cfg.i18n.class.top_caption)
:cssText(args.topcaptionstyle)
:wikitext(args.topcaption)
end
end
if args.pretitle then
root
:tag('tr')
:tag('td')
:addClass(args.topimage and cfg.i18n.class.pretitle_with_top_image
or cfg.i18n.class.pretitle)
:addClass(args.pretitleclass)
:cssText(args.basestyle)
:cssText(args.pretitlestyle)
:wikitext(args.pretitle)
end
else
root
:addClass(cfg.i18n.class.subgroup)
:addClass(args.bodyclass or args.class)
:cssText(args.bodystyle or args.style)
end
if args.title then
if child then
root
:wikitext(args.title)
else
root
:tag('tr')
:tag('th')
:addClass(args.pretitle and cfg.i18n.class.title_with_pretitle
or cfg.i18n.class.title)
:addClass(args.titleclass)
:cssText(args.basestyle)
:cssText(args.titlestyle)
:wikitext(args.title)
end
end
if args.image then
local imageCell = root:tag('tr'):tag('td')
imageCell
:addClass(cfg.i18n.class.image)
:addClass(args.imageclass)
:cssText(args.imagestyle)
:wikitext(args.image)
if args.caption then
imageCell
:tag('div')
:addClass(cfg.i18n.class.caption)
:cssText(args.captionstyle)
:wikitext(args.caption)
end
end
if args.above then
root
:tag('tr')
:tag('td')
:addClass(cfg.i18n.class.above)
:addClass(args.aboveclass)
:cssText(args.abovestyle)
:newline() -- newline required for bullet-points to work
:wikitext(args.above)
end
local rowNums = {}
for k, v in pairs(args) do
k = '' .. k
local num = k:match('^heading(%d+)$') or k:match('^content(%d+)$')
if num then table.insert(rowNums, tonumber(num)) end
end
table.sort(rowNums)
-- remove duplicates from the list (e.g. 3 will be duplicated if both heading3
-- and content3 are specified)
for i = #rowNums, 1, -1 do
if rowNums[i] == rowNums[i - 1] then
table.remove(rowNums, i)
end
end
for i, num in ipairs(rowNums) do
local heading = args['heading' .. num]
if heading then
root
:tag('tr')
:tag('th')
:addClass(cfg.i18n.class.heading)
:addClass(args.headingclass)
:addClass(args['heading' .. num .. 'class'])
:cssText(args.basestyle)
:cssText(args.headingstyle)
:cssText(args['heading' .. num .. 'style'])
:newline()
:wikitext(heading)
end
local content = args['content' .. num]
if content then
root
:tag('tr')
:tag('td')
:addClass(hasSubgroup(content) and cfg.i18n.class.content_with_subgroup
or cfg.i18n.class.content)
:addClass(args.contentclass)
:addClass(args['content' .. num .. 'class'])
:cssText(args.contentstyle)
:cssText(args['content' .. num .. 'style'])
:newline()
:wikitext(content)
:done()
-- Without a linebreak after the </td>, a nested list like
-- "* {{hlist| ...}}" doesn't parse correctly.
:newline()
end
end
if args.below then
root
:tag('tr')
:tag('td')
:addClass(cfg.i18n.class.below)
:addClass(args.belowclass)
:cssText(args.belowstyle)
:newline()
:wikitext(args.below)
end
if not child and has_navbar(args.navbar, args.name) then
root
:tag('tr')
:tag('td')
:addClass(cfg.i18n.class.navbar)
:cssText(args.navbarstyle)
:wikitext(require('Module:Navbar')._navbar{
args.name,
mini = 1,
fontstyle = args.navbarfontstyle
})
end
local base_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = cfg.i18n.templatestyles }
}
local templatestyles = ''
if args['templatestyles'] and args['templatestyles'] ~= '' then
templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['templatestyles'] }
}
end
local child_templatestyles = ''
if args['child templatestyles'] and args['child templatestyles'] ~= '' then
child_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['child templatestyles'] }
}
end
local grandchild_templatestyles = ''
if args['grandchild templatestyles'] and args['grandchild templatestyles'] ~= '' then
grandchild_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
}
end
return table.concat({
add_list_styles(args), -- see [hlist_note] above about ordering
base_templatestyles,
templatestyles,
child_templatestyles,
grandchild_templatestyles,
hiding_templatestyles,
tostring(root),
(child and cfg.i18n.category.child or ''),
categorizeTemplatesWithInlineStyles(args)
})
end
local function list_title(args, is_centered_list_titles, num)
local title_text = trimAndAddAutomaticNewline(args['list' .. num .. 'title']
or cfg.i18n.default_list_title)
local title
if is_centered_list_titles then
-- collapsible can be finicky, so provide some CSS/HTML to support
title = mw.html.create('div')
:addClass(cfg.i18n.class.list_title_centered)
:wikitext(title_text)
else
title = mw.html.create()
:wikitext(title_text)
end
local title_container = mw.html.create('div')
:addClass(cfg.i18n.class.list_title)
-- don't /need/ a listnumtitleclass because you can do
-- .templateclass .listnumclass .sidebar-list-title
:addClass(args.listtitleclass)
:cssText(args.basestyle)
:cssText(args.listtitlestyle)
:cssText(args['list' .. num .. 'titlestyle'])
:node(title)
:done()
return title_container
end
--[[
Main entry point for sidebar with collapsible lists.
Does the work of creating the collapsible lists themselves and including them
into the args.
]]
function p.collapsible(frame)
local args = getArgs(frame)
if not args.name and
frame:getParent():getTitle():gsub(cfg.i18n.pattern.collapse_sandbox, '') ==
cfg.i18n.collapse_title_not_to_add_navbar then
args.navbar = cfg.i18n.navbar_none
end
local contentArgs = {}
local is_centered_list_titles = false
if args['centered list titles'] and args['centered list titles'] ~= '' then
is_centered_list_titles = true
end
for k, v in pairs(args) do
local num = string.match(k, '^list(%d+)$')
if num then
local expand = args.expanded and
(args.expanded == 'all' or args.expanded == args['list' .. num .. 'name'])
local row = mw.html.create('div')
row
:addClass(cfg.i18n.class.list)
:addClass('mw-collapsible')
:addClass((not expand) and 'mw-collapsed' or nil)
:addClass(args['list' .. num .. 'class'])
:cssText(args.listframestyle)
:cssText(args['list' .. num .. 'framestyle'])
:node(list_title(args, is_centered_list_titles, num))
:tag('div')
:addClass(cfg.i18n.class.list_content)
:addClass('mw-collapsible-content')
-- don't /need/ a listnumstyleclass because you can do
-- .templatename .listnumclass .sidebar-list
:addClass(args.listclass)
:cssText(args.liststyle)
:cssText(args['list' .. num .. 'style'])
:wikitext(trimAndAddAutomaticNewline(args['list' .. num]))
contentArgs['content' .. num] = tostring(row)
end
end
for k, v in pairs(contentArgs) do
args[k] = v
end
return p.sidebar(frame, args, cfg.i18n.class.collapse)
end
return p
71fe765846593e025ca2f94371315e9dbb5bb4d2
Module:Sidebar/configuration
828
43
90
89
2023-10-01T08:21:12Z
Reverie
2
1 revision imported
Scribunto
text/plain
return {
i18n = {
child_yes = 'yes',
float_none = 'none',
float_left = 'left',
wrap_true = 'true',
navbar_none = 'none',
navbar_off = 'off',
default_list_title = 'List',
title_not_to_add_navbar = 'Template:Sidebar',
collapse_title_not_to_add_navbar = 'Template:Sidebar with collapsible lists',
templatestyles = 'Module:Sidebar/styles.css',
hlist_templatestyles = 'Hlist/styles.css',
plainlist_templatestyles = 'Plainlist/styles.css',
category = {
child = '[[Category:Pages using sidebar with the child parameter]]',
conversion = '[[Category:Sidebars with styles needing conversion]]'
},
pattern = {
collapse_sandbox = '/sandbox$',
sandbox = '/sandbox$',
subgroup = 'sidebar%-subgroup',
style_conversion = 'style$',
uncategorized_conversion_titles = {
'/[Ss]andbox',
'/[Tt]estcases',
'/[Dd]oc$'
}
},
class = {
sidebar = 'sidebar',
subgroup = 'sidebar-subgroup',
collapse = 'sidebar-collapse',
float_none = 'sidebar-none',
float_left = 'sidebar-left',
wraplinks = 'nowraplinks',
outer_title = 'sidebar-outer-title',
top_image = 'sidebar-top-image',
top_caption = 'sidebar-top-caption',
pretitle = 'sidebar-pretitle',
pretitle_with_top_image = 'sidebar-pretitle-with-top-image',
title = 'sidebar-title',
title_with_pretitle = 'sidebar-title-with-pretitle',
image = 'sidebar-image',
caption = 'sidebar-caption',
above = 'sidebar-above',
heading = 'sidebar-heading',
content = 'sidebar-content',
content_with_subgroup = 'sidebar-content-with-subgroup',
below = 'sidebar-below',
navbar = 'sidebar-navbar',
list = 'sidebar-list',
list_title = 'sidebar-list-title',
list_title_centered = 'sidebar-list-title-c',
list_content = 'sidebar-list-content'
}
}
}
dc2a980ac2162a898f7c21e6d6ba7e994dfeb315
Module:Sidebar/styles.css
828
44
92
91
2023-10-01T08:21:13Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp-template}} */
/* TODO: Invert width design to be "mobile first" */
.sidebar {
/* TODO: Ask if we should have max-width 22em instead */
width: 22em;
/* @noflip */
float: right;
/* @noflip */
clear: right;
/* @noflip */
margin: 0.5em 0 1em 1em;
background: #f8f9fa;
border: 1px solid #aaa;
padding: 0.2em;
text-align: center;
line-height: 1.4em;
font-size: 88%;
border-collapse: collapse;
/* Timeless has display: none on .nomobile at mobile resolutions, so we
* unhide it with display: table and let precedence and proximity win.
*/
display: table;
}
/* Unfortunately, so does Minerva desktop, except Minerva drops an
* !important on the declaration. So we have to be mean for Minerva users.
* Mobile removes the element entirely with `wgMFRemovableClasses` in
* https://github.com/wikimedia/operations-mediawiki-config/blob/master/
wmf-config/InitialiseSettings.php#L16992
* which is why displaying it categorically with display: table works.
* We don't really want to expose the generic user in the wild on mobile to have
* to deal with sidebars. (Maybe the ones with collapsible lists, so that
* might be an improvement. That is blocked on [[:phab:T111565]].)
*/
body.skin-minerva .sidebar {
display: table !important;
/* also, minerva is way too aggressive about other stylings on tables.
* TODO remove when this template gets moved to a div. plans on talk page.
* We always float right on Minerva because that's a lot of extra CSS
* otherwise. */
float: right !important;
margin: 0.5em 0 1em 1em !important;
}
.sidebar-subgroup {
width: 100%;
margin: 0;
border-spacing: 0;
}
.sidebar-left {
/* @noflip */
float: left;
/* @noflip */
clear: left;
/* @noflip */
margin: 0.5em 1em 1em 0;
}
.sidebar-none {
float: none;
clear: both;
/* @noflip */
margin: 0.5em 1em 1em 0;
}
.sidebar-outer-title {
padding: 0 0.4em 0.2em;
font-size: 125%;
line-height: 1.2em;
font-weight: bold;
}
.sidebar-top-image {
padding: 0.4em;
}
.sidebar-top-caption,
.sidebar-pretitle-with-top-image,
.sidebar-caption {
padding: 0.2em 0.4em 0;
line-height: 1.2em;
}
.sidebar-pretitle {
padding: 0.4em 0.4em 0;
line-height: 1.2em;
}
.sidebar-title,
.sidebar-title-with-pretitle {
padding: 0.2em 0.8em;
font-size: 145%;
line-height: 1.2em;
}
.sidebar-title-with-pretitle {
padding: 0.1em 0.4em;
}
.sidebar-image {
padding: 0.2em 0.4em 0.4em;
}
.sidebar-heading {
padding: 0.1em 0.4em;
}
.sidebar-content {
padding: 0 0.5em 0.4em;
}
.sidebar-content-with-subgroup {
padding: 0.1em 0.4em 0.2em;
}
.sidebar-above,
.sidebar-below {
padding: 0.3em 0.8em;
font-weight: bold;
}
.sidebar-collapse .sidebar-above,
.sidebar-collapse .sidebar-below {
border-top: 1px solid #aaa;
border-bottom: 1px solid #aaa;
}
.sidebar-navbar {
text-align: right;
font-size: 115%;
padding: 0 0.4em 0.4em;
}
.sidebar-list-title {
padding: 0 0.4em;
text-align: left;
font-weight: bold;
line-height: 1.6em;
font-size: 105%;
}
/* centered text with mw-collapsible headers is finicky */
.sidebar-list-title-c {
padding: 0 0.4em;
text-align: center;
margin: 0 3.3em;
}
@media (max-width: 720px) {
/* users have wide latitude to set arbitrary width and margin :(
"Super-specific" selector to prevent overriding this appearance by
lower level sidebars too */
body.mediawiki .sidebar {
width: 100% !important;
clear: both;
float: none !important; /* Remove when we div based; Minerva is dumb */
margin-left: 0 !important;
margin-right: 0 !important;
}
/* TODO: We might consider making all links wrap at small resolutions and then
* only introduce nowrap at higher resolutions. Do when we invert the media
* query.
*/
}
7d621b35a37807a103b59075851fe36201204ceb
Template:Div col
10
45
94
93
2023-10-01T08:21:13Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly><templatestyles src="Div col/styles.css"/><!--
--><div class="div-col {{#ifeq:{{{small|}}}|yes|div-col-small}} {{#ifeq:{{{rules|}}}|yes|div-col-rules}} {{{class|}}}" <!--
-->{{#if:{{{colwidth|}}}{{{gap|}}}{{{style|}}}|<!--
-->style="{{#if:{{{colwidth|}}}|column-width: {{{colwidth}}};}}{{#if:{{{gap|}}}|column-gap: {{{gap}}};}}{{#if:{{{style|}}}|{{{style}}}}}"<!--
-->}}><!--
-->{{#if:{{{content|}}}|{{{content}}}</div>}}<!-- Inventory how many pages use small=yes
-->{{#ifeq:{{{small|}}}|yes|[[Category:Pages using div col with small parameter]]}}<!--
--></includeonly>{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using div col with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Div col]] with unknown parameter "_VALUE_"; use colwidth= to specify column size |ignoreblank=y | class | colwidth | content | gap | rules | small | style }}<noinclude>
{{Documentation}}
</noinclude>
6e84133dd867d6c701e7b161878cf66665bb7eb7
Template:Div col/styles.css
10
46
96
95
2023-10-01T08:21:14Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp|small=yes}} */
.div-col {
margin-top: 0.3em;
column-width: 30em;
}
.div-col-small {
font-size: 90%;
}
.div-col-rules {
column-rule: 1px solid #aaa;
}
/* Reset top margin for lists in div col */
.div-col dl,
.div-col ol,
.div-col ul {
margin-top: 0;
}
/* Avoid elements breaking between columns
See also Template:No col break */
.div-col li,
.div-col dd {
page-break-inside: avoid; /* Removed from CSS in favor of break-inside c. 2020 */
break-inside: avoid-column;
}
/* Unbulleted lists */
.plainlist ol,
.plainlist ul {
line-height: inherit;
list-style: none;
margin: 0;
}
.plainlist ol li,
.plainlist ul li {
margin-bottom: 0;
}
76c2c0a042b9164cff638cd44af5ab129702c141
Template:Div col end
10
47
98
97
2023-10-01T08:21:15Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly></div></includeonly><noinclude>
{{Documentation|Template:Div col/doc}}
</noinclude>
78088d41c21d779e3722f220fcc9773dfbbc1e4f
Template:Yesno-no
10
48
100
99
2023-10-01T08:21:15Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{safesubst:<noinclude />yesno|{{{1}}}|yes={{{yes|yes}}}|no={{{no|no}}}|blank={{{blank|no}}}|¬={{{¬|no}}}|def={{{def|no}}}}}<noinclude>
{{Documentation|Template:Yesno/doc}}
<!--Categories go in the doc page referenced above; interwikis go in Wikidata.-->
</noinclude>
1ad7b7800da1b867ead8f6ff8cef76e6201b3b56
Template:Para
10
49
102
101
2023-10-01T08:21:15Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<code class="tpl-para" style="word-break:break-word;{{SAFESUBST:<noinclude />#if:{{{plain|}}}|border: none; background-color: inherit;}} {{SAFESUBST:<noinclude />#if:{{{plain|}}}{{{mxt|}}}{{{green|}}}{{{!mxt|}}}{{{red|}}}|color: {{SAFESUBST:<noinclude />#if:{{{mxt|}}}{{{green|}}}|#006400|{{SAFESUBST:<noinclude />#if:{{{!mxt|}}}{{{red|}}}|#8B0000|inherit}}}};}} {{SAFESUBST:<noinclude />#if:{{{style|}}}|{{{style}}}}}">|{{SAFESUBST:<noinclude />#if:{{{1|}}}|{{{1}}}=}}{{{2|}}}</code><noinclude>
{{Documentation}}
<!--Categories and interwikis go near the bottom of the /doc subpage.-->
</noinclude>
06006deea2ed5d552aab61b4332321ab749ae7e8
Template:Documentation
10
50
104
103
2023-10-01T08:21:16Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}<noinclude>
<!-- Add categories to the /doc subpage -->
</noinclude>
9e62b964e96c4e3d478edecbfcb3c0338ae8a276
Module:Documentation
828
51
106
105
2023-10-01T08:21:16Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module implements {{documentation}}.
-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')
local p = {}
-- Often-used functions.
local ugsub = mw.ustring.gsub
local format = mw.ustring.format
----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------
local function message(cfgKey, valArray, expectType)
--[[
-- Gets a message from the cfg table and formats it if appropriate.
-- The function raises an error if the value from the cfg table is not
-- of the type expectType. The default type for expectType is 'string'.
-- If the table valArray is present, strings such as $1, $2 etc. in the
-- message are substituted with values from the table keys [1], [2] etc.
-- For example, if the message "foo-message" had the value 'Foo $2 bar $1.',
-- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz."
--]]
local msg = cfg[cfgKey]
expectType = expectType or 'string'
if type(msg) ~= expectType then
error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
end
if not valArray then
return msg
end
local function getMessageVal(match)
match = tonumber(match)
return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
end
return ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
end
p.message = message
local function makeWikilink(page, display)
if display then
return format('[[%s|%s]]', page, display)
else
return format('[[%s]]', page)
end
end
p.makeWikilink = makeWikilink
local function makeCategoryLink(cat, sort)
local catns = mw.site.namespaces[14].name
return makeWikilink(catns .. ':' .. cat, sort)
end
p.makeCategoryLink = makeCategoryLink
local function makeUrlLink(url, display)
return format('[%s %s]', url, display)
end
p.makeUrlLink = makeUrlLink
local function makeToolbar(...)
local ret = {}
local lim = select('#', ...)
if lim < 1 then
return nil
end
for i = 1, lim do
ret[#ret + 1] = select(i, ...)
end
-- 'documentation-toolbar'
return format(
'<span class="%s">(%s)</span>',
message('toolbar-class'),
table.concat(ret, ' | ')
)
end
p.makeToolbar = makeToolbar
----------------------------------------------------------------------------
-- Argument processing
----------------------------------------------------------------------------
local function makeInvokeFunc(funcName)
return function (frame)
local args = getArgs(frame, {
valueFunc = function (key, value)
if type(value) == 'string' then
value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
if key == 'heading' or value ~= '' then
return value
else
return nil
end
else
return value
end
end
})
return p[funcName](args)
end
end
----------------------------------------------------------------------------
-- Entry points
----------------------------------------------------------------------------
function p.nonexistent(frame)
if mw.title.getCurrentTitle().subpageText == 'testcases' then
return frame:expandTemplate{title = 'module test cases notice'}
else
return p.main(frame)
end
end
p.main = makeInvokeFunc('_main')
function p._main(args)
--[[
-- This function defines logic flow for the module.
-- @args - table of arguments passed by the user
--]]
local env = p.getEnvironment(args)
local root = mw.html.create()
root
:wikitext(p._getModuleWikitext(args, env))
:wikitext(p.protectionTemplate(env))
:wikitext(p.sandboxNotice(args, env))
:tag('div')
-- 'documentation-container'
:addClass(message('container'))
:attr('role', 'complementary')
:attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil)
:attr('aria-label', args.heading == '' and 'Documentation' or nil)
:newline()
:tag('div')
-- 'documentation'
:addClass(message('main-div-classes'))
:newline()
:wikitext(p._startBox(args, env))
:wikitext(p._content(args, env))
:tag('div')
-- 'documentation-clear'
:addClass(message('clear'))
:done()
:newline()
:done()
:wikitext(p._endBox(args, env))
:done()
:wikitext(p.addTrackingCategories(env))
-- 'Module:Documentation/styles.css'
return mw.getCurrentFrame():extensionTag (
'templatestyles', '', {src=cfg['templatestyles']
}) .. tostring(root)
end
----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------
function p.getEnvironment(args)
--[[
-- Returns a table with information about the environment, including title
-- objects and other namespace- or path-related data.
-- @args - table of arguments passed by the user
--
-- Title objects include:
-- env.title - the page we are making documentation for (usually the current title)
-- env.templateTitle - the template (or module, file, etc.)
-- env.docTitle - the /doc subpage.
-- env.sandboxTitle - the /sandbox subpage.
-- env.testcasesTitle - the /testcases subpage.
--
-- Data includes:
-- env.protectionLevels - the protection levels table of the title object.
-- env.subjectSpace - the number of the title's subject namespace.
-- env.docSpace - the number of the namespace the title puts its documentation in.
-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
--
-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
-- returned will be nil.
--]]
local env, envFuncs = {}, {}
-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
-- returned by that function is memoized in the env table so that we don't call any of the functions
-- more than once. (Nils won't be memoized.)
setmetatable(env, {
__index = function (t, key)
local envFunc = envFuncs[key]
if envFunc then
local success, val = pcall(envFunc)
if success then
env[key] = val -- Memoise the value.
return val
end
end
return nil
end
})
function envFuncs.title()
-- The title object for the current page, or a test page passed with args.page.
local title
local titleArg = args.page
if titleArg then
title = mw.title.new(titleArg)
else
title = mw.title.getCurrentTitle()
end
return title
end
function envFuncs.templateTitle()
--[[
-- The template (or module, etc.) title object.
-- Messages:
-- 'sandbox-subpage' --> 'sandbox'
-- 'testcases-subpage' --> 'testcases'
--]]
local subjectSpace = env.subjectSpace
local title = env.title
local subpage = title.subpageText
if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then
return mw.title.makeTitle(subjectSpace, title.baseText)
else
return mw.title.makeTitle(subjectSpace, title.text)
end
end
function envFuncs.docTitle()
--[[
-- Title object of the /doc subpage.
-- Messages:
-- 'doc-subpage' --> 'doc'
--]]
local title = env.title
local docname = args[1] -- User-specified doc page.
local docpage
if docname then
docpage = docname
else
docpage = env.docpageBase .. '/' .. message('doc-subpage')
end
return mw.title.new(docpage)
end
function envFuncs.sandboxTitle()
--[[
-- Title object for the /sandbox subpage.
-- Messages:
-- 'sandbox-subpage' --> 'sandbox'
--]]
return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
end
function envFuncs.testcasesTitle()
--[[
-- Title object for the /testcases subpage.
-- Messages:
-- 'testcases-subpage' --> 'testcases'
--]]
return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
end
function envFuncs.protectionLevels()
-- The protection levels table of the title object.
return env.title.protectionLevels
end
function envFuncs.subjectSpace()
-- The subject namespace number.
return mw.site.namespaces[env.title.namespace].subject.id
end
function envFuncs.docSpace()
-- The documentation namespace number. For most namespaces this is the
-- same as the subject namespace. However, pages in the Article, File,
-- MediaWiki or Category namespaces must have their /doc, /sandbox and
-- /testcases pages in talk space.
local subjectSpace = env.subjectSpace
if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
return subjectSpace + 1
else
return subjectSpace
end
end
function envFuncs.docpageBase()
-- The base page of the /doc, /sandbox, and /testcases subpages.
-- For some namespaces this is the talk page, rather than the template page.
local templateTitle = env.templateTitle
local docSpace = env.docSpace
local docSpaceText = mw.site.namespaces[docSpace].name
-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
return docSpaceText .. ':' .. templateTitle.text
end
function envFuncs.compareUrl()
-- Diff link between the sandbox and the main template using [[Special:ComparePages]].
local templateTitle = env.templateTitle
local sandboxTitle = env.sandboxTitle
if templateTitle.exists and sandboxTitle.exists then
local compareUrl = mw.uri.canonicalUrl(
'Special:ComparePages',
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
)
return tostring(compareUrl)
else
return nil
end
end
return env
end
----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------
p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext')
function p._getModuleWikitext(args, env)
local currentTitle = mw.title.getCurrentTitle()
if currentTitle.contentModel ~= 'Scribunto' then return end
pcall(require, currentTitle.prefixedText) -- if it fails, we don't care
local moduleWikitext = package.loaded["Module:Module wikitext"]
if moduleWikitext then
return moduleWikitext.main()
end
end
function p.sandboxNotice(args, env)
--[=[
-- Generates a sandbox notice for display above sandbox pages.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'sandbox-notice-image' --> '[[File:Sandbox.svg|50px|alt=|link=]]'
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
-- 'sandbox-notice-pagetype-template' --> '[[Wikipedia:Template test cases|template sandbox]] page'
-- 'sandbox-notice-pagetype-module' --> '[[Wikipedia:Template test cases|module sandbox]] page'
-- 'sandbox-notice-pagetype-other' --> 'sandbox page'
-- 'sandbox-notice-compare-link-display' --> 'diff'
-- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'
-- 'sandbox-notice-testcases-link-display' --> 'test cases'
-- 'sandbox-category' --> 'Template sandboxes'
--]=]
local title = env.title
local sandboxTitle = env.sandboxTitle
local templateTitle = env.templateTitle
local subjectSpace = env.subjectSpace
if not (subjectSpace and title and sandboxTitle and templateTitle
and mw.title.equals(title, sandboxTitle)) then
return nil
end
-- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text".
local omargs = {}
omargs.image = message('sandbox-notice-image')
-- Get the text. We start with the opening blurb, which is something like
-- "This is the template sandbox for [[Template:Foo]] (diff)."
local text = ''
local pagetype
if subjectSpace == 10 then
pagetype = message('sandbox-notice-pagetype-template')
elseif subjectSpace == 828 then
pagetype = message('sandbox-notice-pagetype-module')
else
pagetype = message('sandbox-notice-pagetype-other')
end
local templateLink = makeWikilink(templateTitle.prefixedText)
local compareUrl = env.compareUrl
if compareUrl then
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareLink = makeUrlLink(compareUrl, compareDisplay)
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
else
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
end
-- Get the test cases page blurb if the page exists. This is something like
-- "See also the companion subpage for [[Template:Foo/testcases|test cases]]."
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle.contentModel == "Scribunto" then
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
else
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
end
end
-- Add the sandbox to the sandbox category.
omargs.text = text .. makeCategoryLink(message('sandbox-category'))
-- 'documentation-clear'
return '<div class="' .. message('clear') .. '"></div>'
.. require('Module:Message box').main('ombox', omargs)
end
function p.protectionTemplate(env)
-- Generates the padlock icon in the top right.
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
local protectionLevels = env.protectionLevels
if not protectionLevels then
return nil
end
local editProt = protectionLevels.edit and protectionLevels.edit[1]
local moveProt = protectionLevels.move and protectionLevels.move[1]
if editProt then
-- The page is edit-protected.
return require('Module:Protection banner')._main{
message('protection-reason-edit'), small = true
}
elseif moveProt and moveProt ~= 'autoconfirmed' then
-- The page is move-protected but not edit-protected. Exclude move
-- protection with the level "autoconfirmed", as this is equivalent to
-- no move protection at all.
return require('Module:Protection banner')._main{
action = 'move', small = true
}
else
return nil
end
end
----------------------------------------------------------------------------
-- Start box
----------------------------------------------------------------------------
p.startBox = makeInvokeFunc('_startBox')
function p._startBox(args, env)
--[[
-- This function generates the start box.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
-- which generate the box HTML.
--]]
env = env or p.getEnvironment(args)
local links
local content = args.content
if not content or args[1] then
-- No need to include the links if the documentation is on the template page itself.
local linksData = p.makeStartBoxLinksData(args, env)
if linksData then
links = p.renderStartBoxLinks(linksData)
end
end
-- Generate the start box html.
local data = p.makeStartBoxData(args, env, links)
if data then
return p.renderStartBox(data)
else
-- User specified no heading.
return nil
end
end
function p.makeStartBoxLinksData(args, env)
--[[
-- Does initial processing of data to make the [view] [edit] [history] [purge] links.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'view-link-display' --> 'view'
-- 'edit-link-display' --> 'edit'
-- 'history-link-display' --> 'history'
-- 'purge-link-display' --> 'purge'
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'
-- 'docpage-preload' --> 'Template:Documentation/preload'
-- 'create-link-display' --> 'create'
--]]
local subjectSpace = env.subjectSpace
local title = env.title
local docTitle = env.docTitle
if not title or not docTitle then
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
-- Create link if /doc doesn't exist.
local preload = args.preload
if not preload then
if subjectSpace == 828 then -- Module namespace
preload = message('module-preload')
else
preload = message('docpage-preload')
end
end
return {
title = title,
docTitle = docTitle,
-- View, display, edit, and purge links if /doc exists.
viewLinkDisplay = message('view-link-display'),
editLinkDisplay = message('edit-link-display'),
historyLinkDisplay = message('history-link-display'),
purgeLinkDisplay = message('purge-link-display'),
preload = preload,
createLinkDisplay = message('create-link-display')
}
end
function p.renderStartBoxLinks(data)
--[[
-- Generates the [view][edit][history][purge] or [create][purge] links from the data table.
-- @data - a table of data generated by p.makeStartBoxLinksData
--]]
local docTitle = data.docTitle
-- yes, we do intend to purge the template page on which the documentation appears
local purgeLink = makeWikilink("Special:Purge/" .. data.title.prefixedText, data.purgeLinkDisplay)
if docTitle.exists then
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, data.editLinkDisplay)
local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, data.historyLinkDisplay)
return "[" .. viewLink .. "] [" .. editLink .. "] [" .. historyLink .. "] [" .. purgeLink .. "]"
else
local createLink = makeUrlLink(docTitle:canonicalUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
return "[" .. createLink .. "] [" .. purgeLink .. "]"
end
return ret
end
function p.makeStartBoxData(args, env, links)
--[=[
-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
--
-- Messages:
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
-- 'template-namespace-heading' --> 'Template documentation'
-- 'module-namespace-heading' --> 'Module documentation'
-- 'file-namespace-heading' --> 'Summary'
-- 'other-namespaces-heading' --> 'Documentation'
-- 'testcases-create-link-display' --> 'create'
--]=]
local subjectSpace = env.subjectSpace
if not subjectSpace then
-- Default to an "other namespaces" namespace, so that we get at least some output
-- if an error occurs.
subjectSpace = 2
end
local data = {}
-- Heading
local heading = args.heading -- Blank values are not removed.
if heading == '' then
-- Don't display the start box if the heading arg is defined but blank.
return nil
end
if heading then
data.heading = heading
elseif subjectSpace == 10 then -- Template namespace
data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
elseif subjectSpace == 828 then -- Module namespace
data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
elseif subjectSpace == 6 then -- File namespace
data.heading = message('file-namespace-heading')
else
data.heading = message('other-namespaces-heading')
end
-- Heading CSS
local headingStyle = args['heading-style']
if headingStyle then
data.headingStyleText = headingStyle
else
-- 'documentation-heading'
data.headingClass = message('main-div-heading-class')
end
-- Data for the [view][edit][history][purge] or [create] links.
if links then
-- 'mw-editsection-like plainlinks'
data.linksClass = message('start-box-link-classes')
data.links = links
end
return data
end
function p.renderStartBox(data)
-- Renders the start box html.
-- @data - a table of data generated by p.makeStartBoxData.
local sbox = mw.html.create('div')
sbox
-- 'documentation-startbox'
:addClass(message('start-box-class'))
:newline()
:tag('span')
:addClass(data.headingClass)
:attr('id', 'documentation-heading')
:cssText(data.headingStyleText)
:wikitext(data.heading)
local links = data.links
if links then
sbox:tag('span')
:addClass(data.linksClass)
:attr('id', data.linksId)
:wikitext(links)
end
return tostring(sbox)
end
----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------
p.content = makeInvokeFunc('_content')
function p._content(args, env)
-- Displays the documentation contents
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
env = env or p.getEnvironment(args)
local docTitle = env.docTitle
local content = args.content
if not content and docTitle and docTitle.exists then
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end
-- of docs are interpreted correctly.
return '\n' .. (content or '') .. '\n'
end
p.contentTitle = makeInvokeFunc('_contentTitle')
function p._contentTitle(args, env)
env = env or p.getEnvironment(args)
local docTitle = env.docTitle
if not args.content and docTitle and docTitle.exists then
return docTitle.prefixedText
else
return ''
end
end
----------------------------------------------------------------------------
-- End box
----------------------------------------------------------------------------
p.endBox = makeInvokeFunc('_endBox')
function p._endBox(args, env)
--[=[
-- This function generates the end box (also known as the link box).
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
--]=]
-- Get environment data.
env = env or p.getEnvironment(args)
local subjectSpace = env.subjectSpace
local docTitle = env.docTitle
if not subjectSpace or not docTitle then
return nil
end
-- Check whether we should output the end box at all. Add the end
-- box by default if the documentation exists or if we are in the
-- user, module or template namespaces.
local linkBox = args['link box']
if linkBox == 'off'
or not (
docTitle.exists
or subjectSpace == 2
or subjectSpace == 828
or subjectSpace == 10
)
then
return nil
end
-- Assemble the link box.
local text = ''
if linkBox then
text = text .. linkBox
else
text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]."
if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
-- We are in the user, template or module namespaces.
-- Add sandbox and testcases links.
-- "Editors can experiment in this template's sandbox and testcases pages."
text = text .. (p.makeExperimentBlurb(args, env) or '') .. '<br />'
if not args.content and not args[1] then
-- "Please add categories to the /doc subpage."
-- Don't show this message with inline docs or with an explicitly specified doc page,
-- as then it is unclear where to add the categories.
text = text .. (p.makeCategoriesBlurb(args, env) or '')
end
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template"
end
end
local box = mw.html.create('div')
-- 'documentation-metadata'
box:attr('role', 'note')
:addClass(message('end-box-class'))
-- 'plainlinks'
:addClass(message('end-box-plainlinks'))
:wikitext(text)
:done()
return '\n' .. tostring(box)
end
function p.makeDocPageBlurb(args, env)
--[=[
-- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)".
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'edit-link-display' --> 'edit'
-- 'history-link-display' --> 'history'
-- 'transcluded-from-blurb' -->
-- 'The above [[Wikipedia:Template documentation|documentation]]
-- is [[Help:Transclusion|transcluded]] from $1.'
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'
-- 'create-link-display' --> 'create'
-- 'create-module-doc-blurb' -->
-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
--]=]
local docTitle = env.docTitle
if not docTitle then
return nil
end
local ret
if docTitle.exists then
-- /doc exists; link to it.
local docLink = makeWikilink(docTitle.prefixedText)
local editDisplay = message('edit-link-display')
local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, editDisplay)
local historyDisplay = message('history-link-display')
local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, historyDisplay)
ret = message('transcluded-from-blurb', {docLink})
.. ' '
.. makeToolbar(editLink, historyLink)
.. '<br />'
elseif env.subjectSpace == 828 then
-- /doc does not exist; ask to create it.
local createUrl = docTitle:canonicalUrl{action = 'edit', preload = message('module-preload')}
local createDisplay = message('create-link-display')
local createLink = makeUrlLink(createUrl, createDisplay)
ret = message('create-module-doc-blurb', {createLink})
.. '<br />'
end
return ret
end
function p.makeExperimentBlurb(args, env)
--[[
-- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages."
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'sandbox-link-display' --> 'sandbox'
-- 'sandbox-edit-link-display' --> 'edit'
-- 'compare-link-display' --> 'diff'
-- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox'
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
-- 'sandbox-create-link-display' --> 'create'
-- 'mirror-edit-summary' --> 'Create sandbox version of $1'
-- 'mirror-link-display' --> 'mirror'
-- 'mirror-link-preload' --> 'Template:Documentation/mirror'
-- 'sandbox-link-display' --> 'sandbox'
-- 'testcases-link-display' --> 'testcases'
-- 'testcases-edit-link-display'--> 'edit'
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
-- 'testcases-create-link-display' --> 'create'
-- 'testcases-link-display' --> 'testcases'
-- 'testcases-edit-link-display' --> 'edit'
-- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
-- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases'
-- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.'
-- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.'
--]]
local subjectSpace = env.subjectSpace
local templateTitle = env.templateTitle
local sandboxTitle = env.sandboxTitle
local testcasesTitle = env.testcasesTitle
local templatePage = templateTitle.prefixedText
if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
return nil
end
-- Make links.
local sandboxLinks, testcasesLinks
if sandboxTitle.exists then
local sandboxPage = sandboxTitle.prefixedText
local sandboxDisplay = message('sandbox-link-display')
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
local sandboxEditDisplay = message('sandbox-edit-link-display')
local sandboxEditLink = makeWikilink("Special:EditPage/" .. sandboxPage, sandboxEditDisplay)
local compareUrl = env.compareUrl
local compareLink
if compareUrl then
local compareDisplay = message('compare-link-display')
compareLink = makeUrlLink(compareUrl, compareDisplay)
end
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
else
local sandboxPreload
if subjectSpace == 828 then
sandboxPreload = message('module-sandbox-preload')
else
sandboxPreload = message('template-sandbox-preload')
end
local sandboxCreateUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = sandboxPreload}
local sandboxCreateDisplay = message('sandbox-create-link-display')
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorPreload = message('mirror-link-preload')
local mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
if subjectSpace == 828 then
mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
end
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
end
if testcasesTitle.exists then
local testcasesPage = testcasesTitle.prefixedText
local testcasesDisplay = message('testcases-link-display')
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
local testcasesEditUrl = testcasesTitle:canonicalUrl{action = 'edit'}
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeWikilink("Special:EditPage/" .. testcasesPage, testcasesEditDisplay)
-- for Modules, add testcases run link if exists
if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
local testcasesRunLinkDisplay = message('testcases-run-link-display')
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
else
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
end
else
local testcasesPreload
if subjectSpace == 828 then
testcasesPreload = message('module-testcases-preload')
else
testcasesPreload = message('template-testcases-preload')
end
local testcasesCreateUrl = testcasesTitle:canonicalUrl{action = 'edit', preload = testcasesPreload}
local testcasesCreateDisplay = message('testcases-create-link-display')
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
end
local messageName
if subjectSpace == 828 then
messageName = 'experiment-blurb-module'
else
messageName = 'experiment-blurb-template'
end
return message(messageName, {sandboxLinks, testcasesLinks})
end
function p.makeCategoriesBlurb(args, env)
--[[
-- Generates the text "Please add categories to the /doc subpage."
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'doc-link-display' --> '/doc'
-- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.'
--]]
local docTitle = env.docTitle
if not docTitle then
return nil
end
local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
return message('add-categories-blurb', {docPathLink})
end
function p.makeSubpagesBlurb(args, env)
--[[
-- Generates the "Subpages of this template" link.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'template-pagetype' --> 'template'
-- 'module-pagetype' --> 'module'
-- 'default-pagetype' --> 'page'
-- 'subpages-link-display' --> 'Subpages of this $1'
--]]
local subjectSpace = env.subjectSpace
local templateTitle = env.templateTitle
if not subjectSpace or not templateTitle then
return nil
end
local pagetype
if subjectSpace == 10 then
pagetype = message('template-pagetype')
elseif subjectSpace == 828 then
pagetype = message('module-pagetype')
else
pagetype = message('default-pagetype')
end
local subpagesLink = makeWikilink(
'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
message('subpages-link-display', {pagetype})
)
return message('subpages-blurb', {subpagesLink})
end
----------------------------------------------------------------------------
-- Tracking categories
----------------------------------------------------------------------------
function p.addTrackingCategories(env)
--[[
-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'display-strange-usage-category' --> true
-- 'doc-subpage' --> 'doc'
-- 'testcases-subpage' --> 'testcases'
-- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage'
--
-- /testcases pages in the module namespace are not categorised, as they may have
-- {{documentation}} transcluded automatically.
--]]
local title = env.title
local subjectSpace = env.subjectSpace
if not title or not subjectSpace then
return nil
end
local subpage = title.subpageText
local ret = ''
if message('display-strange-usage-category', nil, 'boolean')
and (
subpage == message('doc-subpage')
or subjectSpace ~= 828 and subpage == message('testcases-subpage')
)
then
ret = ret .. makeCategoryLink(message('strange-usage-category'))
end
return ret
end
return p
268dc89480af10873bfbca5439ae8e61b404f770
Module:Documentation/config
828
52
108
107
2023-10-01T08:21:16Z
Reverie
2
1 revision imported
Scribunto
text/plain
----------------------------------------------------------------------------------------------------
--
-- Configuration for Module:Documentation
--
-- Here you can set the values of the parameters and messages used in Module:Documentation to
-- localise it to your wiki and your language. Unless specified otherwise, values given here
-- should be string values.
----------------------------------------------------------------------------------------------------
local cfg = {} -- Do not edit this line.
----------------------------------------------------------------------------------------------------
-- Protection template configuration
----------------------------------------------------------------------------------------------------
-- cfg['protection-reason-edit']
-- The protection reason for edit-protected templates to pass to
-- [[Module:Protection banner]].
cfg['protection-reason-edit'] = 'template'
--[[
----------------------------------------------------------------------------------------------------
-- Sandbox notice configuration
--
-- On sandbox pages the module can display a template notifying users that the current page is a
-- sandbox, and the location of test cases pages, etc. The module decides whether the page is a
-- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the
-- messages that the notices contains.
----------------------------------------------------------------------------------------------------
--]]
-- cfg['sandbox-notice-image']
-- The image displayed in the sandbox notice.
cfg['sandbox-notice-image'] = '[[File:Sandbox.svg|50px|alt=|link=]]'
--[[
-- cfg['sandbox-notice-pagetype-template']
-- cfg['sandbox-notice-pagetype-module']
-- cfg['sandbox-notice-pagetype-other']
-- The page type of the sandbox page. The message that is displayed depends on the current subject
-- namespace. This message is used in either cfg['sandbox-notice-blurb'] or
-- cfg['sandbox-notice-diff-blurb'].
--]]
cfg['sandbox-notice-pagetype-template'] = '[[Wikipedia:Template test cases|template sandbox]] page'
cfg['sandbox-notice-pagetype-module'] = '[[Wikipedia:Template test cases|module sandbox]] page'
cfg['sandbox-notice-pagetype-other'] = 'sandbox page'
--[[
-- cfg['sandbox-notice-blurb']
-- cfg['sandbox-notice-diff-blurb']
-- cfg['sandbox-notice-diff-display']
-- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence
-- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page
-- type, which is either cfg['sandbox-notice-pagetype-template'],
-- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what
-- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between
-- the sandbox and the main template. The display value of the diff link is set by
-- cfg['sandbox-notice-compare-link-display'].
--]]
cfg['sandbox-notice-blurb'] = 'This is the $1 for $2.'
cfg['sandbox-notice-diff-blurb'] = 'This is the $1 for $2 ($3).'
cfg['sandbox-notice-compare-link-display'] = 'diff'
--[[
-- cfg['sandbox-notice-testcases-blurb']
-- cfg['sandbox-notice-testcases-link-display']
-- cfg['sandbox-notice-testcases-run-blurb']
-- cfg['sandbox-notice-testcases-run-link-display']
-- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page
-- corresponding to this sandbox that they can edit. $1 is a link to the test cases page.
-- cfg['sandbox-notice-testcases-link-display'] is the display value for that link.
-- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page
-- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test
-- cases page, and $2 is a link to the page to run it.
-- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test
-- cases.
--]]
cfg['sandbox-notice-testcases-blurb'] = 'See also the companion subpage for $1.'
cfg['sandbox-notice-testcases-link-display'] = 'test cases'
cfg['sandbox-notice-testcases-run-blurb'] = 'See also the companion subpage for $1 ($2).'
cfg['sandbox-notice-testcases-run-link-display'] = 'run'
-- cfg['sandbox-category']
-- A category to add to all template sandboxes.
cfg['sandbox-category'] = 'Template sandboxes'
----------------------------------------------------------------------------------------------------
-- Start box configuration
----------------------------------------------------------------------------------------------------
-- cfg['documentation-icon-wikitext']
-- The wikitext for the icon shown at the top of the template.
cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
-- cfg['template-namespace-heading']
-- The heading shown in the template namespace.
cfg['template-namespace-heading'] = 'Template documentation'
-- cfg['module-namespace-heading']
-- The heading shown in the module namespace.
cfg['module-namespace-heading'] = 'Module documentation'
-- cfg['file-namespace-heading']
-- The heading shown in the file namespace.
cfg['file-namespace-heading'] = 'Summary'
-- cfg['other-namespaces-heading']
-- The heading shown in other namespaces.
cfg['other-namespaces-heading'] = 'Documentation'
-- cfg['view-link-display']
-- The text to display for "view" links.
cfg['view-link-display'] = 'view'
-- cfg['edit-link-display']
-- The text to display for "edit" links.
cfg['edit-link-display'] = 'edit'
-- cfg['history-link-display']
-- The text to display for "history" links.
cfg['history-link-display'] = 'history'
-- cfg['purge-link-display']
-- The text to display for "purge" links.
cfg['purge-link-display'] = 'purge'
-- cfg['create-link-display']
-- The text to display for "create" links.
cfg['create-link-display'] = 'create'
----------------------------------------------------------------------------------------------------
-- Link box (end box) configuration
----------------------------------------------------------------------------------------------------
-- cfg['transcluded-from-blurb']
-- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page.
cfg['transcluded-from-blurb'] = 'The above [[Wikipedia:Template documentation|documentation]] is [[Help:Transclusion|transcluded]] from $1.'
--[[
-- cfg['create-module-doc-blurb']
-- Notice displayed in the module namespace when the documentation subpage does not exist.
-- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the
-- display cfg['create-link-display'].
--]]
cfg['create-module-doc-blurb'] = 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
----------------------------------------------------------------------------------------------------
-- Experiment blurb configuration
----------------------------------------------------------------------------------------------------
--[[
-- cfg['experiment-blurb-template']
-- cfg['experiment-blurb-module']
-- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages.
-- It is only shown in the template and module namespaces. With the default English settings, it
-- might look like this:
--
-- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
--
-- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links.
--
-- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending
-- on what namespace we are in.
--
-- Parameters:
--
-- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format:
--
-- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display'])
--
-- If the sandbox doesn't exist, it is in the format:
--
-- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display'])
--
-- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload']
-- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display']
-- loads a default edit summary of cfg['mirror-edit-summary'].
--
-- $2 is a link to the test cases page. If the test cases page exists, it is in the following format:
--
-- cfg['testcases-link-display'] (cfg['testcases-edit-link-display'] | cfg['testcases-run-link-display'])
--
-- If the test cases page doesn't exist, it is in the format:
--
-- cfg['testcases-link-display'] (cfg['testcases-create-link-display'])
--
-- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the
-- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current
-- namespace.
--]]
cfg['experiment-blurb-template'] = "Editors can experiment in this template's $1 and $2 pages."
cfg['experiment-blurb-module'] = "Editors can experiment in this module's $1 and $2 pages."
----------------------------------------------------------------------------------------------------
-- Sandbox link configuration
----------------------------------------------------------------------------------------------------
-- cfg['sandbox-subpage']
-- The name of the template subpage typically used for sandboxes.
cfg['sandbox-subpage'] = 'sandbox'
-- cfg['template-sandbox-preload']
-- Preload file for template sandbox pages.
cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox'
-- cfg['module-sandbox-preload']
-- Preload file for Lua module sandbox pages.
cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox'
-- cfg['sandbox-link-display']
-- The text to display for "sandbox" links.
cfg['sandbox-link-display'] = 'sandbox'
-- cfg['sandbox-edit-link-display']
-- The text to display for sandbox "edit" links.
cfg['sandbox-edit-link-display'] = 'edit'
-- cfg['sandbox-create-link-display']
-- The text to display for sandbox "create" links.
cfg['sandbox-create-link-display'] = 'create'
-- cfg['compare-link-display']
-- The text to display for "compare" links.
cfg['compare-link-display'] = 'diff'
-- cfg['mirror-edit-summary']
-- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the
-- template page.
cfg['mirror-edit-summary'] = 'Create sandbox version of $1'
-- cfg['mirror-link-display']
-- The text to display for "mirror" links.
cfg['mirror-link-display'] = 'mirror'
-- cfg['mirror-link-preload']
-- The page to preload when a user clicks the "mirror" link.
cfg['mirror-link-preload'] = 'Template:Documentation/mirror'
----------------------------------------------------------------------------------------------------
-- Test cases link configuration
----------------------------------------------------------------------------------------------------
-- cfg['testcases-subpage']
-- The name of the template subpage typically used for test cases.
cfg['testcases-subpage'] = 'testcases'
-- cfg['template-testcases-preload']
-- Preload file for template test cases pages.
cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases'
-- cfg['module-testcases-preload']
-- Preload file for Lua module test cases pages.
cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases'
-- cfg['testcases-link-display']
-- The text to display for "testcases" links.
cfg['testcases-link-display'] = 'testcases'
-- cfg['testcases-edit-link-display']
-- The text to display for test cases "edit" links.
cfg['testcases-edit-link-display'] = 'edit'
-- cfg['testcases-run-link-display']
-- The text to display for test cases "run" links.
cfg['testcases-run-link-display'] = 'run'
-- cfg['testcases-create-link-display']
-- The text to display for test cases "create" links.
cfg['testcases-create-link-display'] = 'create'
----------------------------------------------------------------------------------------------------
-- Add categories blurb configuration
----------------------------------------------------------------------------------------------------
--[[
-- cfg['add-categories-blurb']
-- Text to direct users to add categories to the /doc subpage. Not used if the "content" or
-- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a
-- link to the /doc subpage with a display value of cfg['doc-link-display'].
--]]
cfg['add-categories-blurb'] = 'Add categories to the $1 subpage.'
-- cfg['doc-link-display']
-- The text to display when linking to the /doc subpage.
cfg['doc-link-display'] = '/doc'
----------------------------------------------------------------------------------------------------
-- Subpages link configuration
----------------------------------------------------------------------------------------------------
--[[
-- cfg['subpages-blurb']
-- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a
-- display value of cfg['subpages-link-display']. In the English version this blurb is simply
-- the link followed by a period, and the link display provides the actual text.
--]]
cfg['subpages-blurb'] = '$1.'
--[[
-- cfg['subpages-link-display']
-- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'],
-- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in
-- the template namespace, the module namespace, or another namespace.
--]]
cfg['subpages-link-display'] = 'Subpages of this $1'
-- cfg['template-pagetype']
-- The pagetype to display for template pages.
cfg['template-pagetype'] = 'template'
-- cfg['module-pagetype']
-- The pagetype to display for Lua module pages.
cfg['module-pagetype'] = 'module'
-- cfg['default-pagetype']
-- The pagetype to display for pages other than templates or Lua modules.
cfg['default-pagetype'] = 'page'
----------------------------------------------------------------------------------------------------
-- Doc link configuration
----------------------------------------------------------------------------------------------------
-- cfg['doc-subpage']
-- The name of the subpage typically used for documentation pages.
cfg['doc-subpage'] = 'doc'
-- cfg['docpage-preload']
-- Preload file for template documentation pages in all namespaces.
cfg['docpage-preload'] = 'Template:Documentation/preload'
-- cfg['module-preload']
-- Preload file for Lua module documentation pages.
cfg['module-preload'] = 'Template:Documentation/preload-module-doc'
----------------------------------------------------------------------------------------------------
-- HTML and CSS configuration
----------------------------------------------------------------------------------------------------
-- cfg['templatestyles']
-- The name of the TemplateStyles page where CSS is kept.
-- Sandbox CSS will be at Module:Documentation/sandbox/styles.css when needed.
cfg['templatestyles'] = 'Module:Documentation/styles.css'
-- cfg['container']
-- Class which can be used to set flex or grid CSS on the
-- two child divs documentation and documentation-metadata
cfg['container'] = 'documentation-container'
-- cfg['main-div-classes']
-- Classes added to the main HTML "div" tag.
cfg['main-div-classes'] = 'documentation'
-- cfg['main-div-heading-class']
-- Class for the main heading for templates and modules and assoc. talk spaces
cfg['main-div-heading-class'] = 'documentation-heading'
-- cfg['start-box-class']
-- Class for the start box
cfg['start-box-class'] = 'documentation-startbox'
-- cfg['start-box-link-classes']
-- Classes used for the [view][edit][history] or [create] links in the start box.
-- mw-editsection-like is per [[Wikipedia:Village pump (technical)/Archive 117]]
cfg['start-box-link-classes'] = 'mw-editsection-like plainlinks'
-- cfg['end-box-class']
-- Class for the end box.
cfg['end-box-class'] = 'documentation-metadata'
-- cfg['end-box-plainlinks']
-- Plainlinks
cfg['end-box-plainlinks'] = 'plainlinks'
-- cfg['toolbar-class']
-- Class added for toolbar links.
cfg['toolbar-class'] = 'documentation-toolbar'
-- cfg['clear']
-- Just used to clear things.
cfg['clear'] = 'documentation-clear'
----------------------------------------------------------------------------------------------------
-- Tracking category configuration
----------------------------------------------------------------------------------------------------
-- cfg['display-strange-usage-category']
-- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage
-- or a /testcases subpage. This should be a boolean value (either true or false).
cfg['display-strange-usage-category'] = true
-- cfg['strange-usage-category']
-- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a
-- /doc subpage or a /testcases subpage.
cfg['strange-usage-category'] = 'Wikipedia pages with strange ((documentation)) usage'
--[[
----------------------------------------------------------------------------------------------------
-- End configuration
--
-- Don't edit anything below this line.
----------------------------------------------------------------------------------------------------
--]]
return cfg
71b68ed73088f1a59d61acf06bbee9fde6677f03
Module:Documentation/styles.css
828
53
110
109
2023-10-01T08:21:17Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp|small=yes}} */
.documentation,
.documentation-metadata {
border: 1px solid #a2a9b1;
background-color: #ecfcf4;
clear: both;
}
.documentation {
margin: 1em 0 0 0;
padding: 1em;
}
.documentation-metadata {
margin: 0.2em 0; /* same margin left-right as .documentation */
font-style: italic;
padding: 0.4em 1em; /* same padding left-right as .documentation */
}
.documentation-startbox {
padding-bottom: 3px;
border-bottom: 1px solid #aaa;
margin-bottom: 1ex;
}
.documentation-heading {
font-weight: bold;
font-size: 125%;
}
.documentation-clear { /* Don't want things to stick out where they shouldn't. */
clear: both;
}
.documentation-toolbar {
font-style: normal;
font-size: 85%;
}
ce0e629c92e3d825ab9fd927fe6cc37d9117b6cb
Template:Sandbox other
10
54
112
111
2023-10-01T08:21:17Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#if:{{#ifeq:{{#invoke:String|sublength|s={{SUBPAGENAME}}|i=0|len=7}}|sandbox|1}}{{#ifeq:{{SUBPAGENAME}}|doc|1}}{{#invoke:String|match|{{PAGENAME}}|/sandbox/styles.css$|plain=false|nomatch=}}|{{{1|}}}|{{{2|}}}}}<!--
--><noinclude>{{documentation}}</noinclude>
91e4ae891d6b791615152c1fbc971414961ba872
Template:Documentation subpage
10
55
114
113
2023-10-01T08:21:18Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly><!--
-->{{#ifeq:{{lc:{{SUBPAGENAME}}}} |{{{override|doc}}}
| <!--(this template has been transcluded on a /doc or /{{{override}}} page)-->
</includeonly><!--
-->{{#ifeq:{{{doc-notice|show}}} |show
| {{Mbox
| type = notice
| style = margin-bottom:1.0em;
| image = [[File:Edit-copy green.svg|40px|alt=|link=]]
| text =
{{strong|This is a [[Wikipedia:Template documentation|documentation]] [[Wikipedia:Subpages|subpage]]}} for {{terminate sentence|{{{1|[[:{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}}}}<br />It may contain usage information, [[Wikipedia:Categorization|categories]] and other content that is not part of the original {{#if:{{{text2|}}} |{{{text2}}} |{{#if:{{{text1|}}} |{{{text1}}} |{{#ifeq:{{SUBJECTSPACE}} |{{ns:User}} |{{lc:{{SUBJECTSPACE}}}} template page |{{#if:{{SUBJECTSPACE}} |{{lc:{{SUBJECTSPACE}}}} page|article}}}}}}}}.
}}
}}<!--
-->{{DEFAULTSORT:{{{defaultsort|{{PAGENAME}}}}}}}<!--
-->{{#if:{{{inhibit|}}} |<!--(don't categorize)-->
| <includeonly><!--
-->{{#ifexist:{{NAMESPACE}}:{{BASEPAGENAME}}
| [[Category:{{#switch:{{SUBJECTSPACE}} |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
| [[Category:Documentation subpages without corresponding pages]]
}}<!--
--></includeonly>
}}<!--
(completing initial #ifeq: at start of template:)
--><includeonly>
| <!--(this template has not been transcluded on a /doc or /{{{override}}} page)-->
}}<!--
--></includeonly><noinclude>{{Documentation}}</noinclude>
41ca90af0945442788a2dbd08c8c54a61a23c057
Template:Template link with link off
10
56
116
115
2023-10-01T08:21:18Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#Invoke:Template link general|main|nowrap=yes|nolink=yes}}</includeonly><noinclude>
{{Documentation|1=Template:Tlg/doc
|content = {{tlg/doc|tlf}}
}}
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
b099fea5d1f36b0b4b9cb253ad3a9f4e095f6851
Template:Tlf
10
57
118
117
2023-10-01T08:21:19Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Template link with link off]]
{{Redirect category shell|
{{R from move}}
}}
52759e1d3f7c9aa4a03d0b7d4f84f4c6adf53edf
Template:High-use
10
58
120
119
2023-10-01T08:21:19Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:High-use|main|1={{{1|}}}|2={{{2|}}}|info={{{info|}}}|demo={{{demo|}}}|form={{{form|}}}|expiry={{{expiry|}}}|system={{{system|}}}}}<noinclude>
{{Documentation}}
<!-- Add categories to the /doc subpage; interwiki links go to Wikidata, thank you! -->
</noinclude>
a3322d1bd47ac03df14fa2090855cff4fede9bc7
Template:TemplateData header
10
59
122
121
2023-10-01T08:21:20Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<div class="templatedata-header">{{#if:{{{noheader|}}}|<!--
noheader:
-->{{Template parameter usage|based=y}}|<!--
+header:
-->This is the {{#if:{{{nolink|}}}|<!--
+header, nolink TD
-->TemplateData|<!--
+header, +link [[TD]]; DEFAULT:
-->[[Wikipedia:TemplateData|TemplateData]]}}<!--
e.o. #if:nolink; DEFAULT:
--> for this template used by [[mw:Extension:TemplateWizard|TemplateWizard]], [[Wikipedia:VisualEditor|VisualEditor]] and other tools. {{Template parameter usage|based=y}}<!--
e.o. #if:noheader
-->}}
'''TemplateData for {{{1|{{BASEPAGENAME}}}}}'''
</div><includeonly><!--
check parameters
-->{{#invoke:Check for unknown parameters|check
|unknown={{template other|1=[[Category:Pages using TemplateData header with unknown parameters|_VALUE_]]}}
|template=Template:TemplateData header
|1 |nolink |noheader
|preview=<div class="error" style="font-weight:normal">Unknown parameter '_VALUE_' in [[Template:TemplateData header]].</div>
}}<!--
-->{{template other|{{sandbox other||
[[Category:Templates using TemplateData]]
}}}}</includeonly><!--
--><noinclude>{{Documentation}}</noinclude>
ddfbb4ae793846b96d4c06330417fa6ed4da2adc
Template:Template parameter usage
10
60
124
123
2023-10-01T08:21:21Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#switch:{{{label|}}}
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|C|c}}lick here] to see a monthly parameter usage report for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|this template}} in articles{{#ifeq:{{yesno-no|{{{based}}}}}|yes| based on {{#if:{{{1|}}}|its|this}} TemplateData}}.
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|P|p}}arameter usage report]{{#ifeq:{{yesno-no|{{{based}}}}}|yes| based on {{#if:{{{1|}}}|its|this}} TemplateData}}
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|P|p}}arameter usage report] for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|[[Template:{{ROOTPAGENAME}}]]}}{{#ifeq:{{yesno-no|{{{based}}}}}|yes| based on {{#if:{{{1|}}}|its|this}} TemplateData}}.
|#default=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{{label|}}}]{{#ifeq:{{yesno-no|{{{based}}}}}|yes| based on {{#if:{{{1|}}}|its|this}} TemplateData}}
}}<noinclude>
{{documentation}}
</noinclude>
10a89e6a4bc63a1427518ea21bf94b8f623a7391
Module:High-use
828
61
126
125
2023-10-01T08:21:21Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p = {}
-- _fetch looks at the "demo" argument.
local _fetch = require('Module:Transclusion_count').fetch
local yesno = require('Module:Yesno')
function p.num(frame, count)
if count == nil then
if yesno(frame.args['fetch']) == false then
if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
else
count = _fetch(frame)
end
end
-- Build output string
local return_value = ""
if count == nil then
if frame.args[1] == "risk" then
return_value = "a very large number of"
else
return_value = "many"
end
else
-- Use 2 significant figures for smaller numbers and 3 for larger ones
local sigfig = 2
if count >= 100000 then
sigfig = 3
end
-- Prepare to round to appropriate number of sigfigs
local f = math.floor(math.log10(count)) - sigfig + 1
-- Round and insert "approximately" or "+" when appropriate
if (frame.args[2] == "yes") or (mw.ustring.sub(frame.args[1],-1) == "+") then
-- Round down
return_value = string.format("%s+", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) ) * (10^(f))) )
else
-- Round to nearest
return_value = string.format("approximately %s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) )
end
-- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yes
if count and count > 250000 and not yesno (frame:getParent().args['no-percent']) then
local percent = math.floor( ( (count/frame:callParserFunction('NUMBEROFPAGES', 'R') ) * 100) + 0.5)
if percent >= 1 then
return_value = string.format("%s pages, or roughly %s%% of all", return_value, percent)
end
end
end
return return_value
end
-- Actions if there is a large (greater than or equal to 100,000) transclusion count
function p.risk(frame)
local return_value = ""
if frame.args[1] == "risk" then
return_value = "risk"
else
local count = _fetch(frame)
if count and count >= 100000 then return_value = "risk" end
end
return return_value
end
function p.text(frame, count)
-- Only show the information about how this template gets updated if someone
-- is actually editing the page and maybe trying to update the count.
local bot_text = (frame:preprocess("{{REVISIONID}}") == "") and "\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]])." or ''
if count == nil then
if yesno(frame.args['fetch']) == false then
if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
else
count = _fetch(frame)
end
end
local title = mw.title.getCurrentTitle()
if title.subpageText == "doc" or title.subpageText == "sandbox" then
title = title.basePageTitle
end
local systemMessages = frame.args['system']
if frame.args['system'] == '' then
systemMessages = nil
end
-- This retrieves the project URL automatically to simplify localiation.
local templateCount = ('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format(
mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'),
mw.uri.encode(title.fullText), p.num(frame, count))
local used_on_text = "'''This " .. (mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template") .. ' is used ';
if systemMessages then
used_on_text = used_on_text .. systemMessages ..
((count and count > 2000) and ("''', and " .. templateCount) or ("'''"))
else
used_on_text = used_on_text .. templateCount .. "'''"
end
local sandbox_text = ("%s's [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages, or in your own [[%s]]. "):format(
(mw.title.getCurrentTitle().namespace == 828 and "module" or "template"),
title.fullText, title.fullText,
mw.title.getCurrentTitle().namespace == 828 and "Module:Sandbox|module sandbox" or "Wikipedia:User pages#SUB|user subpage"
)
local infoArg = frame.args["info"] ~= "" and frame.args["info"]
if (systemMessages or frame.args[1] == "risk" or (count and count >= 100000) ) then
local info = systemMessages and '.<br/>Changes to it can cause immediate changes to the Wikipedia user interface.' or '.'
if infoArg then
info = info .. "<br />" .. infoArg
end
sandbox_text = info .. '<br /> To avoid major disruption' ..
(count and count >= 100000 and ' and server load' or '') ..
', any changes should be tested in the ' .. sandbox_text ..
'The tested changes can be added to this page in a single edit. '
else
sandbox_text = (infoArg and ('.<br />' .. infoArg .. ' C') or ' and c') ..
'hanges may be widely noticed. Test changes in the ' .. sandbox_text
end
local discussion_text = systemMessages and 'Please discuss changes ' or 'Consider discussing changes '
if frame.args["2"] and frame.args["2"] ~= "" and frame.args["2"] ~= "yes" then
discussion_text = string.format("%sat [[%s]]", discussion_text, frame.args["2"])
else
discussion_text = string.format("%son the [[%s|talk page]]", discussion_text, title.talkPageTitle.fullText )
end
return used_on_text .. sandbox_text .. discussion_text .. " before implementing them." .. bot_text
end
function p.main(frame)
local count = nil
if yesno(frame.args['fetch']) == false then
if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
else
count = _fetch(frame)
end
local image = "[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]"
local type_param = "style"
local epilogue = ''
if frame.args['system'] and frame.args['system'] ~= '' then
image = "[[File:Ambox important.svg|40px|alt=Warning|link=]]"
type_param = "content"
local nocat = frame:getParent().args['nocat'] or frame.args['nocat']
local categorise = (nocat == '' or not yesno(nocat))
if categorise then
epilogue = frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}')
end
elseif (frame.args[1] == "risk" or (count and count >= 100000)) then
image = "[[File:Ambox warning orange.svg|40px|alt=Warning|link=]]"
type_param = "content"
end
if frame.args["form"] == "editnotice" then
return frame:expandTemplate{
title = 'editnotice',
args = {
["image"] = image,
["text"] = p.text(frame, count),
["expiry"] = (frame.args["expiry"] or "")
}
} .. epilogue
else
return require('Module:Message box').main('ombox', {
type = type_param,
image = image,
text = p.text(frame, count),
expiry = (frame.args["expiry"] or "")
}) .. epilogue
end
end
return p
134551888e066954a89c109d2faa8af71a4454a4
Module:Transclusion count
828
62
128
127
2023-10-01T08:21:21Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p = {}
function p.fetch(frame)
local template = nil
local return_value = nil
-- Use demo parameter if it exists, otherswise use current template name
local namespace = mw.title.getCurrentTitle().namespace
if frame.args["demo"] and frame.args["demo"] ~= "" then
template = mw.ustring.gsub(frame.args["demo"],"^[Tt]emplate:","")
elseif namespace == 10 then -- Template namespace
template = mw.title.getCurrentTitle().text
elseif namespace == 828 then -- Module namespace
template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text)
end
-- If in template or module namespace, look up count in /data
if template ~= nil then
namespace = mw.title.new(template, "Template").namespace
if namespace == 10 or namespace == 828 then
template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
template = mw.ustring.gsub(template, "/sandbox$", "") -- strip /sandbox from end
local index = mw.ustring.sub(mw.title.new(template).text,1,1)
local status, data = pcall(function ()
return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other")))
end)
if status then
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])
end
end
end
-- If database value doesn't exist, use value passed to template
if return_value == nil and frame.args[1] ~= nil then
local arg1=mw.ustring.match(frame.args[1], '[%d,]+')
if arg1 and arg1 ~= '' then
return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R'))
end
end
return return_value
end
-- Tabulate this data for [[Wikipedia:Database reports/Templates transcluded on the most pages]]
function p.tabulate(frame)
local list = {}
for i = 65, 91 do
local data = mw.loadData('Module:Transclusion count/data/' .. ((i == 91) and 'other' or string.char(i)))
for name, count in pairs(data) do
table.insert(list, {mw.title.new(name, "Template").fullText, count})
end
end
table.sort(list, function(a, b)
return (a[2] == b[2]) and (a[1] < b[1]) or (a[2] > b[2])
end)
local lang = mw.getContentLanguage();
for i = 1, #list do
list[i] = ('|-\n| %d || [[%s]] || %s\n'):format(i, list[i][1]:gsub('_', ' '), lang:formatNum(list[i][2]))
end
return table.concat(list)
end
return p
000ef6bcbf7b66e727870b0c300c4009da300513
Module:Lua banner
828
63
130
129
2023-10-01T08:21:22Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module implements the {{lua}} template.
local yesno = require('Module:Yesno')
local mList = require('Module:List')
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')
local p = {}
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('^%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
function p._main(args)
local modules = mTableTools.compressSparseArray(args)
local box = p.renderBox(modules)
local trackingCategories = p.renderTrackingCategories(args, modules)
return box .. trackingCategories
end
function p.renderBox(modules)
local boxArgs = {}
if #modules < 1 then
boxArgs.text = '<strong class="error">Error: no modules specified</strong>'
else
local moduleLinks = {}
for i, module in ipairs(modules) do
moduleLinks[i] = string.format('[[:%s]]', module)
local maybeSandbox = mw.title.new(module .. '/sandbox')
if maybeSandbox.exists then
moduleLinks[i] = moduleLinks[i] .. string.format(' ([[:%s|sandbox]])', maybeSandbox.fullText)
end
end
local moduleList = mList.makeList('bulleted', moduleLinks)
local title = mw.title.getCurrentTitle()
if title.subpageText == "doc" then
title = title.basePageTitle
end
if title.contentModel == "Scribunto" then
boxArgs.text = 'This module depends on the following other modules:' .. moduleList
else
boxArgs.text = 'This template uses [[Wikipedia:Lua|Lua]]:\n' .. moduleList
end
end
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.image = '[[File:Lua-Logo.svg|30px|alt=|link=]]'
return mMessageBox.main('mbox', boxArgs)
end
function p.renderTrackingCategories(args, modules, titleObj)
if yesno(args.nocat) then
return ''
end
local cats = {}
-- Error category
if #modules < 1 then
cats[#cats + 1] = 'Lua templates with errors'
end
-- Lua templates category
titleObj = titleObj or mw.title.getCurrentTitle()
local subpageBlacklist = {
doc = true,
sandbox = true,
sandbox2 = true,
testcases = true
}
if not subpageBlacklist[titleObj.subpageText] then
local protCatName
if titleObj.namespace == 10 then
local category = args.category
if not category then
local categories = {
['Module:String'] = 'Templates based on the String Lua module',
['Module:Math'] = 'Templates based on the Math Lua module',
['Module:BaseConvert'] = 'Templates based on the BaseConvert Lua module',
['Module:Citation/CS1'] = 'Templates based on the Citation/CS1 Lua module'
}
category = modules[1] and categories[modules[1]]
category = category or 'Lua-based templates'
end
cats[#cats + 1] = category
protCatName = "Templates using under-protected Lua modules"
elseif titleObj.namespace == 828 then
protCatName = "Modules depending on under-protected modules"
end
if not args.noprotcat and protCatName then
local protLevels = {
autoconfirmed = 1,
extendedconfirmed = 2,
templateeditor = 3,
sysop = 4
}
local currentProt
if titleObj.id ~= 0 then
-- id is 0 (page does not exist) if am previewing before creating a template.
currentProt = titleObj.protectionLevels["edit"][1]
end
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
for i, module in ipairs(modules) do
if module ~= "WP:libraryUtil" then
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
if moduleProt < currentProt then
cats[#cats + 1] = protCatName
break
end
end
end
end
end
for i, cat in ipairs(cats) do
cats[i] = string.format('[[Category:%s]]', cat)
end
return table.concat(cats)
end
return p
03ec1b34a40121efc562c0c64a67ebbf57d56dff
Module:Parameter names example
828
64
132
131
2023-10-01T08:21:22Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module implements {{parameter names example}}.
local p = {}
local function makeParam(s)
local lb = '{'
local rb = '}'
return lb:rep(3) .. s .. rb:rep(3)
end
local function italicize(s)
return "''" .. s .. "''"
end
local function plain(s)
return s
end
function p._main(args, frame)
-- Find how we want to format the arguments to the template.
local formatFunc
if args._display == 'italics' or args._display == 'italic' then
formatFunc = italicize
elseif args._display == 'plain' then
formatFunc = plain
else
formatFunc = makeParam
end
-- Build the table of template arguments.
local targs = {}
for k, v in pairs(args) do
if type(k) == 'number' then
targs[v] = formatFunc(v)
elseif not k:find('^_') then
targs[k] = v
end
end
--targs['nocat'] = 'yes';
--targs['categories'] = 'no';
--targs['demo'] = 'yes';
-- Find the template name.
local template
if args._template then
template = args._template
else
local currentTitle = mw.title.getCurrentTitle()
if currentTitle.prefixedText:find('/sandbox$') then
template = currentTitle.prefixedText
else
template = currentTitle.basePageTitle.prefixedText
end
end
-- Call the template with the arguments.
frame = frame or mw.getCurrentFrame()
local success, result = pcall(
frame.expandTemplate,
frame,
{title = template, args = targs}
)
if success then
return result
else
return ''
end
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Parameter names example'
})
return p._main(args, frame)
end
return p
fdf94fb7a5dc1fabf118d60488a02f1e65b0df24
Template:Lua
10
65
134
133
2023-10-01T08:21:23Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#invoke:Lua banner|main}}</includeonly><noinclude>
{{Lua|Module:Lua banner}}
{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
dba3962144dacd289dbc34f50fbe0a7bf6d7f2f7
Template:Parameter names example
10
66
136
135
2023-10-01T08:21:24Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#invoke:Parameter names example|main}}</includeonly><noinclude>
{{Documentation}}
</noinclude>
de1e29d6ebc113e9d1649ea6a976625885db8a2f
Template:Category link with count
10
67
138
137
2023-10-01T08:21:24Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
[[:Category:{{#invoke:string|replace|1={{{1}}}|2=^:?[Cc]ategory:|3=|plain=false}}|<!--
-->{{#if:{{{name|}}}|{{{name}}}|Category:{{#invoke:string|replace|1={{{1}}}|2=^:?[Cc]ategory:|3=|plain=false}}}}<!--
-->]] ({{PAGESINCATEGORY:{{#invoke:string|replace|1={{{1}}}|2=^:?[Cc]ategory:|3=|plain=false}}|{{{2|all}}}}})<noinclude>
{{Documentation}}
</noinclude>
f93f1540b8c157703bd6d24ae35c35bef745981d
Template:Suppress categories
10
68
140
139
2023-10-01T08:21:25Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{{{{|safesubst:}}}#invoke:Suppress categories|main}}</includeonly><noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
1f9c6065201d31d4c70f982129b5babbb809ae8c
Module:Suppress categories
828
69
142
141
2023-10-01T08:21:25Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This is a simple module to strip categories from wikitext. It does
-- not support nested links or magic words like __TOC__, etc. Even so,
-- it should still handle most categories.
local p = {}
-- Detects if a category link is valid or not. If it is valid,
-- the function returns the blank string. If not, the input
-- is returned with no changes.
local function processCategory( all, submatch )
local beforePipe = mw.ustring.match( submatch, '^(.-)[%s_]*|[%s_]*.-$' )
beforePipe = beforePipe or submatch
if mw.ustring.match( beforePipe, '[%[%]<>{}%c\n]' ) then
return all
else
return ''
end
end
-- Preprocess the content if we aren't being called from #invoke,
-- and pass it to gsub to remove valid category links.
local function suppress( content, isPreprocessed )
if not isPreprocessed then
content = mw.getCurrentFrame():preprocess( content )
end
content = mw.ustring.gsub(
content,
'(%[%[[%s_]*[cC][aA][tT][eE][gG][oO][rR][yY][%s_]*:[%s_]*(.-)[%s_]*%]%])',
processCategory
)
return content
end
-- Get the content to suppress categories from, and find
-- whether the content has already been preprocessed. (If the
-- module is called from #invoke, it has been preprocessed already.)
function p.main( frame )
local content, isPreprocessed
if frame == mw.getCurrentFrame() then
content = frame:getParent().args[1]
if frame.args[1] then
content = frame.args[1]
end
isPreprocessed = true
else
content = frame
isPreprocessed = false
end
return suppress( content, isPreprocessed )
end
return p
0ec3903841c489357a879434c5dc23c11d182c78
Module:Transclusion count/data/I
828
70
144
143
2023-10-01T08:21:26Z
Reverie
2
1 revision imported
Scribunto
text/plain
return {
["IAAF_name"] = 2100,
["IAST"] = 6400,
["IBDB_name"] = 9100,
["ICD10"] = 4700,
["ICD9"] = 4400,
["ICS"] = 2900,
["IDN"] = 3400,
["IMDb_episode"] = 10000,
["IMDb_episodes"] = 2700,
["IMDb_name"] = 154000,
["IMDb_title"] = 189000,
["IMO_Number"] = 4100,
["IMSLP"] = 8300,
["INA"] = 2100,
["IND"] = 7600,
["INR"] = 6500,
["INRConvert"] = 5700,
["INRConvert/CurrentRate"] = 5600,
["INRConvert/USD"] = 5600,
["INRConvert/out"] = 5600,
["IOC_profile"] = 5200,
["IP"] = 2600,
["IPA"] = 142000,
["IPA-de"] = 8100,
["IPA-es"] = 7900,
["IPA-fr"] = 44000,
["IPA-it"] = 6000,
["IPA-nl"] = 3900,
["IPA-pl"] = 4100,
["IPA-pt"] = 3300,
["IPA-ru"] = 2700,
["IPA-sl"] = 6900,
["IPA-th"] = 3000,
["IPA_audio_link"] = 3500,
["IPA_link"] = 3500,
["IPAc-cmn"] = 2300,
["IPAc-en"] = 48000,
["IPAc-pl"] = 51000,
["IPC_athlete"] = 2800,
["IPSummary"] = 78000,
["IP_summary"] = 79000,
["IPtalk"] = 18000,
["IPuser"] = 7100,
["IPvandal"] = 2700,
["IRC"] = 7300,
["IRI"] = 2300,
["IRL"] = 5500,
["IRN"] = 3600,
["ISBN"] = 462000,
["ISBN?"] = 2100,
["ISBNT"] = 39000,
["ISBN_missing"] = 2600,
["ISFDB_name"] = 4100,
["ISFDB_title"] = 4600,
["ISL"] = 2100,
["ISO_15924/script-example-character"] = 2800,
["ISO_15924/wp-article"] = 2800,
["ISO_15924/wp-article/format"] = 2800,
["ISO_15924/wp-article/label"] = 2700,
["ISO_3166_code"] = 519000,
["ISO_3166_name"] = 16000,
["ISO_639_name"] = 8100,
["ISP"] = 5300,
["ISR"] = 4900,
["ISSN"] = 12000,
["ISSN_link"] = 30000,
["ISTAT"] = 8100,
["ISU_figure_skater"] = 2500,
["ITA"] = 17000,
["ITF"] = 6300,
["ITF_profile"] = 9000,
["ITIS"] = 4400,
["ITN_talk"] = 10000,
["ITN_talk/date"] = 10000,
["IUCN_banner"] = 15000,
["I_sup"] = 4600,
["Iaaf_name"] = 7200,
["Ice_hockey"] = 19000,
["Ice_hockey_stats"] = 17000,
["Icehockeystats"] = 12000,
["Icon"] = 581000,
["If"] = 272000,
["If_all"] = 6400,
["If_between"] = 3800,
["If_both"] = 155000,
["If_empty"] = 3660000,
["If_first_display_both"] = 73000,
["If_in_page"] = 10000,
["If_last_display_both"] = 30000,
["If_preview"] = 58000,
["If_then_show"] = 289000,
["Ifempty"] = 4000,
["Ifeq"] = 16000,
["Iferror_then_show"] = 3300,
["Ifexist_not_redirect"] = 1300000,
["Ifnotempty"] = 14000,
["Ifnumber"] = 36000,
["Ifsubst"] = 446000,
["Ih"] = 7500,
["Ill"] = 117000,
["Illm"] = 6700,
["Image_frame"] = 4900,
["Image_label"] = 4500,
["Image_label_begin"] = 3800,
["Image_label_end"] = 3800,
["Image_label_small"] = 2600,
["Image_needed"] = 4500,
["Image_other"] = 272000,
["Image_requested"] = 167000,
["Image_requested/Category_helper"] = 159000,
["Imbox"] = 917000,
["Imdb_name"] = 5400,
["Imdb_title"] = 4000,
["Import_style"] = 11000,
["Import_style/inputbox.css"] = 11000,
["Importance"] = 5640000,
["Importance/colour"] = 5660000,
["Importance_mask"] = 10400000,
["Improve_categories"] = 7000,
["Improve_documentation"] = 2400,
["In_class"] = 5900,
["In_lang"] = 356000,
["In_progress"] = 3200,
["In_string"] = 75000,
["In_title"] = 19000,
["Inactive_WikiProject_banner"] = 205000,
["Inactive_userpage_blanked"] = 4900,
["Include-USGov"] = 29000,
["Incomplete_list"] = 23000,
["Inconclusive"] = 2100,
["Increase"] = 43000,
["Incumbent_pope"] = 4300,
["Indent"] = 4400,
["IndexFungorum"] = 2200,
["Indian_English"] = 4300,
["Indian_Rupee"] = 10000,
["Indian_railway_code"] = 3200,
["Inflation"] = 21000,
["Inflation-fn"] = 5400,
["Inflation-year"] = 4500,
["Inflation/IN/startyear"] = 5600,
["Inflation/UK"] = 4400,
["Inflation/UK/dataset"] = 4400,
["Inflation/UK/startyear"] = 4400,
["Inflation/US"] = 12000,
["Inflation/US-GDP"] = 2400,
["Inflation/US-GDP/dataset"] = 2400,
["Inflation/US-GDP/startyear"] = 2400,
["Inflation/US/dataset"] = 12000,
["Inflation/US/startyear"] = 12000,
["Inflation/fn"] = 6200,
["Inflation/year"] = 25000,
["Info"] = 7300,
["Infobox"] = 3230000,
["Infobox/Columns"] = 2400,
["Infobox/mobileviewfix.css"] = 147000,
["Infobox3cols"] = 17000,
["Infobox_AFL_biography"] = 14000,
["Infobox_Aircraft_Begin"] = 5300,
["Infobox_Aircraft_Type"] = 4700,
["Infobox_Athletics_Championships"] = 2700,
["Infobox_Australian_place"] = 15000,
["Infobox_CFL_biography"] = 2200,
["Infobox_COA_wide"] = 3200,
["Infobox_Canada_electoral_district"] = 2500,
["Infobox_Canadian_Football_League_biography"] = 5700,
["Infobox_Canadian_Football_League_biography/position"] = 5700,
["Infobox_Chinese"] = 20000,
["Infobox_Chinese/Chinese"] = 2700,
["Infobox_Chinese/Footer"] = 8700,
["Infobox_Chinese/Header"] = 8700,
["Infobox_Chinese/Korean"] = 17000,
["Infobox_Christian_leader"] = 18000,
["Infobox_French_commune"] = 38000,
["Infobox_GAA_player"] = 2700,
["Infobox_Gaelic_games_player"] = 5000,
["Infobox_German_location"] = 13000,
["Infobox_German_place"] = 14000,
["Infobox_Grand_Prix_race_report"] = 2000,
["Infobox_Greece_place"] = 2800,
["Infobox_Greek_Dimos"] = 2800,
["Infobox_Hindu_temple"] = 2400,
["Infobox_Indian_constituency"] = 4700,
["Infobox_Indian_constituency/defaultdata"] = 4700,
["Infobox_Italian_comune"] = 8100,
["Infobox_Korean_name"] = 15000,
["Infobox_Korean_name/categories"] = 15000,
["Infobox_MLB_yearly"] = 3100,
["Infobox_NASCAR_race_report"] = 2200,
["Infobox_NCAA_team_season"] = 18000,
["Infobox_NFL_biography"] = 28000,
["Infobox_NFL_player"] = 7700,
["Infobox_NFL_team_season"] = 3900,
["Infobox_NRHP"] = 72000,
["Infobox_NRHP/conv"] = 18000,
["Infobox_NRHP/locmapin2region"] = 66000,
["Infobox_Officeholder"] = 4800,
["Infobox_Olympic_event"] = 7300,
["Infobox_Olympic_event/games_text"] = 7300,
["Infobox_Paralympic_event"] = 2600,
["Infobox_Paralympic_event/games_text"] = 2600,
["Infobox_Politician"] = 2200,
["Infobox_Romanian_subdivision"] = 3200,
["Infobox_Russian_district"] = 2000,
["Infobox_Russian_inhabited_locality"] = 4500,
["Infobox_SCOTUS_case"] = 3700,
["Infobox_Site_of_Special_Scientific_Interest"] = 2000,
["Infobox_Swiss_town"] = 2800,
["Infobox_Switzerland_municipality"] = 2900,
["Infobox_Turkey_place"] = 19000,
["Infobox_U.S._county"] = 3000,
["Infobox_U.S._county/district"] = 3000,
["Infobox_UK_constituency"] = 2100,
["Infobox_UK_constituency/year"] = 2100,
["Infobox_UK_legislation"] = 3300,
["Infobox_UK_place"] = 26000,
["Infobox_UK_place/NoDialCode"] = 8000,
["Infobox_UK_place/NoPostCode"] = 3100,
["Infobox_UK_place/area"] = 2400,
["Infobox_UK_place/dist"] = 2500,
["Infobox_UK_place/local"] = 26000,
["Infobox_UK_place/styles.css"] = 26000,
["Infobox_UN_resolution"] = 2300,
["Infobox_US_Supreme_Court_case"] = 3800,
["Infobox_US_Supreme_Court_case/courts"] = 3800,
["Infobox_Wikipedia_user"] = 9800,
["Infobox_YouTube_personality"] = 2700,
["Infobox_YouTube_personality/styles.css"] = 2700,
["Infobox_academic"] = 14000,
["Infobox_aircraft_begin"] = 14000,
["Infobox_aircraft_occurrence"] = 2300,
["Infobox_aircraft_type"] = 12000,
["Infobox_airline"] = 4600,
["Infobox_airport"] = 15000,
["Infobox_airport/datatable"] = 15000,
["Infobox_album"] = 162000,
["Infobox_album/color"] = 192000,
["Infobox_album/link"] = 162000,
["Infobox_anatomy"] = 4500,
["Infobox_ancient_site"] = 5400,
["Infobox_animanga/Footer"] = 6800,
["Infobox_animanga/Header"] = 6800,
["Infobox_animanga/Print"] = 5500,
["Infobox_animanga/Video"] = 4700,
["Infobox_architect"] = 3700,
["Infobox_artist"] = 28000,
["Infobox_artist_discography"] = 5900,
["Infobox_artwork"] = 11000,
["Infobox_athlete"] = 2800,
["Infobox_automobile"] = 8400,
["Infobox_award"] = 13000,
["Infobox_badminton_player"] = 3200,
["Infobox_baseball_biography"] = 28000,
["Infobox_baseball_biography/style"] = 28000,
["Infobox_baseball_biography/styles.css"] = 28000,
["Infobox_basketball_biography"] = 21000,
["Infobox_basketball_biography/style"] = 21000,
["Infobox_basketball_club"] = 3000,
["Infobox_beauty_pageant"] = 2400,
["Infobox_bilateral_relations"] = 4400,
["Infobox_body_of_water"] = 18000,
["Infobox_book"] = 52000,
["Infobox_boxer"] = 5700,
["Infobox_bridge"] = 6000,
["Infobox_building"] = 27000,
["Infobox_character"] = 7600,
["Infobox_chess_biography"] = 3900,
["Infobox_chess_player"] = 3200,
["Infobox_church"] = 15000,
["Infobox_church/denomination"] = 15000,
["Infobox_church/font_color"] = 15000,
["Infobox_civil_conflict"] = 2400,
["Infobox_civilian_attack"] = 5500,
["Infobox_college_coach"] = 12000,
["Infobox_college_football_game"] = 2100,
["Infobox_college_sports_team_season"] = 40000,
["Infobox_college_sports_team_season/link"] = 40000,
["Infobox_college_sports_team_season/name"] = 40000,
["Infobox_college_sports_team_season/succession"] = 40000,
["Infobox_college_sports_team_season/team"] = 40000,
["Infobox_comic_book_title"] = 3000,
["Infobox_comics_character"] = 3600,
["Infobox_comics_creator"] = 3500,
["Infobox_comics_creator/styles.css"] = 3500,
["Infobox_company"] = 83000,
["Infobox_computing_device"] = 2300,
["Infobox_concert"] = 3300,
["Infobox_constituency"] = 5400,
["Infobox_country"] = 6400,
["Infobox_country/formernext"] = 6000,
["Infobox_country/imagetable"] = 5200,
["Infobox_country/multirow"] = 8300,
["Infobox_country/status_text"] = 2800,
["Infobox_country/styles.css"] = 6500,
["Infobox_country_at_games"] = 15000,
["Infobox_country_at_games/core"] = 15000,
["Infobox_country_at_games/see_also"] = 12000,
["Infobox_court_case"] = 4700,
["Infobox_court_case/images"] = 2400,
["Infobox_cricket_tournament"] = 2300,
["Infobox_cricketer"] = 32000,
["Infobox_cricketer/career"] = 32000,
["Infobox_cricketer/national_side"] = 7500,
["Infobox_criminal"] = 6400,
["Infobox_curler"] = 2600,
["Infobox_cycling_race_report"] = 4500,
["Infobox_cyclist"] = 16000,
["Infobox_dam"] = 5700,
["Infobox_designation_list"] = 20000,
["Infobox_designation_list/entry"] = 17000,
["Infobox_dim"] = 6900,
["Infobox_dim/core"] = 6900,
["Infobox_diocese"] = 3800,
["Infobox_drug"] = 9800,
["Infobox_drug/chemical_formula"] = 9800,
["Infobox_drug/data_page_link"] = 9800,
["Infobox_drug/formatATC"] = 9600,
["Infobox_drug/formatCASnumber"] = 9800,
["Infobox_drug/formatChEBI"] = 9800,
["Infobox_drug/formatChEMBL"] = 9800,
["Infobox_drug/formatChemDBNIAID"] = 9800,
["Infobox_drug/formatChemSpider"] = 9800,
["Infobox_drug/formatCompTox"] = 9800,
["Infobox_drug/formatDrugBank"] = 9800,
["Infobox_drug/formatIUPHARBPS"] = 9800,
["Infobox_drug/formatJmol"] = 9800,
["Infobox_drug/formatKEGG"] = 9800,
["Infobox_drug/formatPDBligand"] = 9100,
["Infobox_drug/formatPubChemCID"] = 9800,
["Infobox_drug/formatPubChemSID"] = 9800,
["Infobox_drug/formatUNII"] = 9800,
["Infobox_drug/legal_status"] = 10000,
["Infobox_drug/licence"] = 9800,
["Infobox_drug/maintenance_categories"] = 9800,
["Infobox_drug/non-ref-space"] = 4200,
["Infobox_drug/pregnancy_category"] = 9800,
["Infobox_drug/title"] = 9800,
["Infobox_election"] = 30000,
["Infobox_election/row"] = 30000,
["Infobox_election/shortname"] = 28000,
["Infobox_enzyme"] = 5100,
["Infobox_ethnic_group"] = 7300,
["Infobox_event"] = 5400,
["Infobox_family"] = 2100,
["Infobox_figure_skater"] = 4200,
["Infobox_film"] = 156000,
["Infobox_film/short_description"] = 152000,
["Infobox_film_awards"] = 2600,
["Infobox_film_awards/link"] = 2600,
["Infobox_film_awards/style"] = 2600,
["Infobox_food"] = 6900,
["Infobox_football_biography"] = 206000,
["Infobox_football_club"] = 27000,
["Infobox_football_club_season"] = 20000,
["Infobox_football_league"] = 2600,
["Infobox_football_league_season"] = 19000,
["Infobox_football_match"] = 5900,
["Infobox_football_tournament_season"] = 8000,
["Infobox_former_subdivision"] = 3300,
["Infobox_former_subdivision/styles.css"] = 3300,
["Infobox_galaxy"] = 2100,
["Infobox_game"] = 2600,
["Infobox_game_score"] = 3400,
["Infobox_gene"] = 13000,
["Infobox_given_name"] = 4000,
["Infobox_golfer"] = 4400,
["Infobox_golfer/highest_ranking"] = 4400,
["Infobox_government_agency"] = 10000,
["Infobox_government_cabinet"] = 2600,
["Infobox_gridiron_football_person"] = 2400,
["Infobox_gridiron_football_person/position"] = 5700,
["Infobox_gymnast"] = 3400,
["Infobox_handball_biography"] = 4900,
["Infobox_historic_site"] = 11000,
["Infobox_horseraces"] = 2600,
["Infobox_hospital"] = 6300,
["Infobox_hospital/care_system"] = 6300,
["Infobox_hospital/lists"] = 6300,
["Infobox_ice_hockey_biography"] = 20000,
["Infobox_ice_hockey_player"] = 19000,
["Infobox_ice_hockey_team"] = 3000,
["Infobox_ice_hockey_team_season"] = 2000,
["Infobox_international_football_competition"] = 5800,
["Infobox_islands"] = 8800,
["Infobox_islands/area"] = 9300,
["Infobox_islands/density"] = 9300,
["Infobox_islands/length"] = 8900,
["Infobox_islands/styles.css"] = 8800,
["Infobox_journal"] = 9700,
["Infobox_journal/Abbreviation_search"] = 9600,
["Infobox_journal/Bluebook_check"] = 9400,
["Infobox_journal/Former_check"] = 9400,
["Infobox_journal/ISO_4_check"] = 9400,
["Infobox_journal/ISSN-eISSN"] = 9500,
["Infobox_journal/Indexing_search"] = 9500,
["Infobox_journal/MathSciNet_check"] = 9400,
["Infobox_journal/NLM_check"] = 9400,
["Infobox_journal/frequency"] = 8600,
["Infobox_lake"] = 4200,
["Infobox_language"] = 9500,
["Infobox_language/family-color"] = 11000,
["Infobox_language/genetic"] = 6500,
["Infobox_language/linguistlist"] = 9500,
["Infobox_language/ref"] = 7100,
["Infobox_legislature"] = 3600,
["Infobox_library"] = 2200,
["Infobox_lighthouse"] = 2600,
["Infobox_lighthouse/light"] = 2600,
["Infobox_locomotive"] = 4900,
["Infobox_magazine"] = 7600,
["Infobox_manner_of_address"] = 3300,
["Infobox_mapframe"] = 80000,
["Infobox_martial_artist"] = 5700,
["Infobox_martial_artist/record"] = 5700,
["Infobox_medal_templates"] = 423000,
["Infobox_medical_condition"] = 10000,
["Infobox_medical_condition_(new)"] = 8200,
["Infobox_medical_details"] = 2000,
["Infobox_military_conflict"] = 22000,
["Infobox_military_installation"] = 9800,
["Infobox_military_person"] = 45000,
["Infobox_military_unit"] = 26000,
["Infobox_mine"] = 2100,
["Infobox_model"] = 2300,
["Infobox_monument"] = 2000,
["Infobox_mountain"] = 28000,
["Infobox_multi-sport_competition_event"] = 2400,
["Infobox_museum"] = 10000,
["Infobox_musical_artist"] = 121000,
["Infobox_musical_artist/color"] = 121000,
["Infobox_musical_artist/hCard_class"] = 313000,
["Infobox_musical_composition"] = 2900,
["Infobox_name"] = 7400,
["Infobox_name_module"] = 7000,
["Infobox_newspaper"] = 9700,
["Infobox_nobility"] = 2500,
["Infobox_noble"] = 7300,
["Infobox_officeholder"] = 219000,
["Infobox_officeholder/office"] = 224000,
["Infobox_official_post"] = 8100,
["Infobox_organization"] = 36000,
["Infobox_pageant_titleholder"] = 2900,
["Infobox_park"] = 7500,
["Infobox_person"] = 474000,
["Infobox_person/Wikidata"] = 4700,
["Infobox_person/height"] = 103000,
["Infobox_person/length"] = 7000,
["Infobox_person/weight"] = 66000,
["Infobox_philosopher"] = 3400,
["Infobox_planet"] = 4700,
["Infobox_play"] = 3900,
["Infobox_political_party"] = 14000,
["Infobox_power_station"] = 3000,
["Infobox_prepared_food"] = 3100,
["Infobox_professional_wrestler"] = 4300,
["Infobox_professional_wrestling_event"] = 2700,
["Infobox_protected_area"] = 14000,
["Infobox_protein_family"] = 2100,
["Infobox_publisher"] = 2400,
["Infobox_racehorse"] = 5500,
["Infobox_racing_driver"] = 3900,
["Infobox_racing_driver_series_section"] = 2000,
["Infobox_radio_station"] = 22000,
["Infobox_rail"] = 2900,
["Infobox_rail_line"] = 7300,
["Infobox_rail_service"] = 2900,
["Infobox_rail_service/doc"] = 2900,
["Infobox_reality_competition_season"] = 3500,
["Infobox_record_label"] = 4000,
["Infobox_recurring_event"] = 6400,
["Infobox_religious_biography"] = 5300,
["Infobox_religious_building"] = 12000,
["Infobox_religious_building/color"] = 17000,
["Infobox_restaurant"] = 2900,
["Infobox_river"] = 30000,
["Infobox_river/calcunit"] = 30000,
["Infobox_river/discharge"] = 30000,
["Infobox_river/row-style"] = 30000,
["Infobox_river/source"] = 30000,
["Infobox_road"] = 24000,
["Infobox_road/meta/mask/category"] = 24000,
["Infobox_road/meta/mask/country"] = 24000,
["Infobox_road/styles.css"] = 25000,
["Infobox_road_small"] = 2300,
["Infobox_rockunit"] = 6400,
["Infobox_royalty"] = 22000,
["Infobox_royalty/short_description"] = 12000,
["Infobox_rugby_biography"] = 16000,
["Infobox_rugby_biography/correct_date"] = 16000,
["Infobox_rugby_biography/depcheck"] = 15000,
["Infobox_rugby_league_biography"] = 9900,
["Infobox_rugby_league_biography/PLAYER"] = 9800,
["Infobox_rugby_team"] = 2600,
["Infobox_sailboat_specifications"] = 2300,
["Infobox_saint"] = 5000,
["Infobox_school"] = 38000,
["Infobox_school/short_description"] = 38000,
["Infobox_school_district"] = 5700,
["Infobox_school_district/styles.css"] = 5700,
["Infobox_scientist"] = 48000,
["Infobox_service_record"] = 2600,
["Infobox_settlement"] = 562000,
["Infobox_settlement/areadisp"] = 238000,
["Infobox_settlement/columns"] = 94000,
["Infobox_settlement/columns/styles.css"] = 94000,
["Infobox_settlement/densdisp"] = 437000,
["Infobox_settlement/impus"] = 82000,
["Infobox_settlement/lengthdisp"] = 169000,
["Infobox_settlement/link"] = 94000,
["Infobox_settlement/metric"] = 210000,
["Infobox_settlement/pref"] = 293000,
["Infobox_settlement/styles.css"] = 562000,
["Infobox_ship_begin"] = 41000,
["Infobox_ship_career"] = 37000,
["Infobox_ship_characteristics"] = 41000,
["Infobox_ship_class_overview"] = 4100,
["Infobox_ship_image"] = 40000,
["Infobox_shopping_mall"] = 3500,
["Infobox_short_story"] = 2400,
["Infobox_skier"] = 2500,
["Infobox_soap_character"] = 2900,
["Infobox_software"] = 14000,
["Infobox_software/simple"] = 14000,
["Infobox_song"] = 76000,
["Infobox_song/color"] = 76000,
["Infobox_song/link"] = 76000,
["Infobox_spaceflight"] = 3600,
["Infobox_spaceflight/styles.css"] = 3600,
["Infobox_sport_event"] = 2200,
["Infobox_sports_competition_event"] = 17000,
["Infobox_sports_competition_event/medalrow"] = 11000,
["Infobox_sports_league"] = 5000,
["Infobox_sports_season"] = 5400,
["Infobox_sports_team"] = 2200,
["Infobox_sportsperson"] = 106000,
["Infobox_stadium"] = 3500,
["Infobox_station"] = 55000,
["Infobox_station/doc"] = 55000,
["Infobox_station/services"] = 55000,
["Infobox_station/styles.css"] = 55000,
["Infobox_street"] = 3400,
["Infobox_swimmer"] = 9400,
["Infobox_television"] = 57000,
["Infobox_television/Short_description"] = 54000,
["Infobox_television_channel"] = 6200,
["Infobox_television_episode"] = 12000,
["Infobox_television_episode/styles.css"] = 12000,
["Infobox_television_season"] = 9500,
["Infobox_television_station"] = 3700,
["Infobox_tennis_biography"] = 10000,
["Infobox_tennis_event"] = 2500,
["Infobox_tennis_tournament_event"] = 19000,
["Infobox_tennis_tournament_year"] = 9200,
["Infobox_tennis_tournament_year/color"] = 28000,
["Infobox_tennis_tournament_year/footer"] = 28000,
["Infobox_train"] = 2300,
["Infobox_union"] = 2100,
["Infobox_university"] = 26000,
["Infobox_user"] = 2700,
["Infobox_venue"] = 18000,
["Infobox_video_game"] = 28000,
["Infobox_video_game/styles.css"] = 28000,
["Infobox_volleyball_biography"] = 5400,
["Infobox_weapon"] = 7300,
["Infobox_website"] = 7700,
["Infobox_writer"] = 39000,
["Information"] = 101000,
["Information/styles.css"] = 101000,
["Inline_block"] = 4500,
["Inprogress"] = 2400,
["Input_link"] = 32000,
["Instagram"] = 11000,
["Interlanguage_link"] = 155000,
["Interlanguage_link_multi"] = 19000,
["Internet_Archive_author"] = 19000,
["Internet_Archive_film"] = 2500,
["Intitle"] = 12000,
["Invalid_SVG"] = 3600,
["Invalid_SVG/styles.css"] = 3600,
["Iptalk"] = 17000,
["IranCensus2006"] = 47000,
["IranNCSGN"] = 3200,
["Iran_Census_2006"] = 47000,
["Irc"] = 2100,
["Irish_place_name"] = 2600,
["IsIPAddress"] = 38000,
["IsValidPageName"] = 142000,
["Is_country_in_Central_America"] = 13000,
["Is_country_in_the_Caribbean"] = 14000,
["Is_interwiki_link"] = 6100,
["Is_italic_taxon"] = 479000,
["Is_redirect"] = 27000,
["Isbn"] = 7500,
["Isfdb_name"] = 3700,
["Isfdb_title"] = 4400,
["Isnumeric"] = 210000,
["Iso2continent"] = 35000,
["Iso2country"] = 23000,
["Iso2country/article"] = 22000,
["Iso2country/data"] = 23000,
["Iso2nationality"] = 227000,
["Issubst"] = 72000,
["Isu_name"] = 2200,
["Italic_dab2"] = 5300,
["Italic_title"] = 285000,
["Italic_title_prefixed"] = 8700,
["Italics_colon"] = 3800,
["Italictitle"] = 4300,
["Ivm"] = 5700,
["Ivm/styles.css"] = 5700,
["Ivmbox"] = 123000,
["Ivory_messagebox"] = 142000,
["Module:I18n/complex_date"] = 66000,
["Module:IP"] = 131000,
["Module:IPA"] = 142000,
["Module:IPA/data"] = 128000,
["Module:IPA/styles.css"] = 114000,
["Module:IPA_symbol"] = 4800,
["Module:IPA_symbol/data"] = 4800,
["Module:IPAc-en"] = 48000,
["Module:IPAc-en/data"] = 48000,
["Module:IPAc-en/phonemes"] = 48000,
["Module:IPAc-en/pronunciation"] = 48000,
["Module:IPAddress"] = 188000,
["Module:ISO_3166"] = 1040000,
["Module:ISO_3166/data/AT"] = 2500,
["Module:ISO_3166/data/BA"] = 3400,
["Module:ISO_3166/data/CA"] = 2500,
["Module:ISO_3166/data/CN"] = 2100,
["Module:ISO_3166/data/DE"] = 14000,
["Module:ISO_3166/data/ES"] = 3600,
["Module:ISO_3166/data/FR"] = 38000,
["Module:ISO_3166/data/GB"] = 6400,
["Module:ISO_3166/data/GR"] = 3100,
["Module:ISO_3166/data/IN"] = 29000,
["Module:ISO_3166/data/IR"] = 8200,
["Module:ISO_3166/data/National"] = 1040000,
["Module:ISO_3166/data/PL"] = 6700,
["Module:ISO_3166/data/RS"] = 3200,
["Module:ISO_3166/data/RU"] = 25000,
["Module:ISO_3166/data/US"] = 85000,
["Module:ISO_639_name"] = 20000,
["Module:ISOdate"] = 66000,
["Module:Icon"] = 581000,
["Module:Icon/data"] = 581000,
["Module:If_empty"] = 3660000,
["Module:If_in_page"] = 10000,
["Module:If_preview"] = 295000,
["Module:If_preview/configuration"] = 295000,
["Module:If_preview/styles.css"] = 295000,
["Module:Import_style"] = 11000,
["Module:In_lang"] = 357000,
["Module:Indent"] = 4400,
["Module:Infobox"] = 4110000,
["Module:Infobox/dates"] = 69000,
["Module:Infobox/styles.css"] = 4360000,
["Module:Infobox3cols"] = 297000,
["Module:InfoboxImage"] = 4420000,
["Module:Infobox_body_of_water_tracking"] = 18000,
["Module:Infobox_cyclist_tracking"] = 16000,
["Module:Infobox_gene"] = 13000,
["Module:Infobox_mapframe"] = 404000,
["Module:Infobox_military_conflict"] = 22000,
["Module:Infobox_military_conflict/styles.css"] = 22000,
["Module:Infobox_multi-lingual_name"] = 20000,
["Module:Infobox_multi-lingual_name/data"] = 20000,
["Module:Infobox_power_station"] = 3000,
["Module:Infobox_road"] = 25000,
["Module:Infobox_road/browselinks"] = 25000,
["Module:Infobox_road/errors"] = 24000,
["Module:Infobox_road/length"] = 25000,
["Module:Infobox_road/locations"] = 24000,
["Module:Infobox_road/map"] = 25000,
["Module:Infobox_road/route"] = 25000,
["Module:Infobox_road/sections"] = 24000,
["Module:Infobox_television"] = 57000,
["Module:Infobox_television_disambiguation_check"] = 63000,
["Module:Infobox_television_episode"] = 12000,
["Module:Infobox_television_season_disambiguation_check"] = 9000,
["Module:Infobox_television_season_name"] = 9500,
["Module:Internet_Archive"] = 19000,
["Module:IrelandByCountyCatNav"] = 3300,
["Module:Is_infobox_in_lead"] = 377000,
["Module:Is_instance"] = 335000,
["Module:Italic_title"] = 1120000,
["Module:Italic_title2"] = 5300,
}
96976089c1e9db8d200dbe641eaed9ec564df70a
Template:Infobox/doc
10
71
146
145
2023-10-01T08:21:29Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{Documentation subpage}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
{{distinguish|Template:Userbox}}
{{#ifeq:{{SUBPAGENAME}}|sandbox||{{High-use}}}}
{{Lua|Module:Infobox}}
{{Parameter names example
|name={{PAGENAME}} <!--|child |subbox |decat--> |title |above |subheader |subheader1 |subheader2={{{subheader2}}}<br/>......
|image|caption |image1|caption1 |image2|caption2={{{caption2}}}<br/>......
|header1=<div style="border-top:1px dashed #ccc;">{{{header1}}}<br/>{{nobold|( ''or'' )}}</div>
|label2={{{label1}}} |data2={{{data1}}}
|data3=( ''or'' ) |data4=<div style="padding-bottom:0.25em;border-bottom:1px dashed #ccc;">{{{data1}}}</div>
|header5={{{header2}}}<br/><div style="padding:0.75em 0 0.5em;">{{nobold|( ''or'' )}}</div>
|label6={{{label2}}} |data6={{{data2}}}
|data7=( ''or'' ) |data8=<div style="padding-bottom:0.25em;border-bottom:1px dashed #ccc;">{{{data2}}}</div>
|data9=<div style="padding:0.75em 0 0.5em;">( ''etc'' )</div>
|below
}}
This template is intended as a meta template: a template used for constructing other templates. '''Note''': In general, it is not meant for use directly in an article, but can be used on a one-off basis if required. [[Help:Infobox]] contains an introduction about the recommended content and design of infoboxes; [[Wikipedia:Manual of Style/Infoboxes]] contains additional style guidelines. See [[WP:List of infoboxes]] and [[:Category:Infobox templates]] for lists of prepared topic-specific infoboxes.
== Usage ==
{{tlf|Infobox}} is a meta-template: used to organise an actual <nowiki>{{Infobox sometopic}}</nowiki> template (like {{tl|Infobox building}}).
For <code><nowiki>[[Template:Infobox sometopic]]</nowiki></code>, template code then looks like this, simplified:
<syntaxhighlight lang="wikitext">
{{Infobox
| name = {{{name|{{PAGENAME}}}}}
| image = {{{image|}}}
| caption1 = {{{caption|}}}
| label1 = Former names
| data1 = {{{former_names|}}}
| header2 = General information
| label3 = Status
| data3 = {{{status|}}}
... <!-- etc. -->
}}
</syntaxhighlight>
== Optional control parameters ==
; name : If this parameter is present, "view/talk/edit" links will be added to the bottom of the infobox pointing to the named page, prefixed by <code>Template:</code> if no namespace is specified. You may use the value <nowiki>{{subst:PAGENAME}}</nowiki>; however, this is rarely what you want because it will send users clicking these links in an infobox to the template code rather than the data in the infobox they probably want to change.
; child : See the [[#Embedding|Embedding]] section for details. If this is set to "yes", this child infobox should be titled but have no name parameter. This parameter is empty by default, set it to "yes" to activate it.
; subbox : See the [[#Subboxes|Subboxes]] section for details. If this is set to "yes", this subbox should be titled but have no name parameter. This parameter is empty by default, set to "yes" to activate it. It has no effect if the '''child''' parameter is also set to "yes".
; decat : If this is set to "yes", the current page will not be autocategorized in a maintenance category when the generated infobox has some problems or no visible data section. Leave empty by default or set to "yes" to activate it.
; autoheaders: If this is set to any non-blank value, headers which are not followed by data fields are suppressed. See the "[[#Hiding headers when all its data fields are empty|hiding headers when all its data fields are empty]]" section for more details.
== Content parameters ==
=== Title ===
There are two different ways to put a title on an infobox. One contains the title inside the infobox's border in the uppermost cell of the table, the other puts it as a caption on top of the table. You can use them both together, or just one or the other, or neither (though this is not recommended):
; title : Text to put in the caption over the top of the table (or as section header before the whole content of this table, if this is a child infobox). For [[Wikipedia:Manual of Style/Accessibility#Tables|accessibility reasons]], this is the most recommended alternative.
; above : Text to put within the uppermost cell of the table.
; subheader(n) : additional title fields which fit below {{{title}}} and {{{above}}}, but before images.
Examples:
{{Infobox
| name = Infobox/doc
| title = Text in caption over infobox
| subheader = Subheader of the infobox
| header = (the rest of the infobox goes here)
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| name = {{subst:PAGENAME}}
| title = Text in caption over infobox
| subheader = Subheader of the infobox
| header = (the rest of the infobox goes here)
}}
</syntaxhighlight>{{clear}}
{{Infobox
| name = Infobox/doc
| above = Text in uppermost cell of infobox
| subheader = Subheader of the infobox
| subheader2 = Second subheader of the infobox
| header = (the rest of the infobox goes here)
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| name = {{subst:PAGENAME}}
| above = Text in uppermost cell of infobox
| subheader = Subheader of the infobox
| subheader2 = Second subheader of the infobox
| header = (the rest of the infobox goes here)
}}
</syntaxhighlight>{{clear}}
=== Illustration images ===
; image(n) : images to display at the top of the template. Use full image syntax, for example <nowiki>[[File:example.png|200px|alt=Example alt text]]</nowiki>. Image is centered by default. See [[WP:ALT]] for more on alt text.
; caption(n) : Text to put underneath the images.
=== Main data ===
; header(n) : Text to use as a header in row n.
; label(n) : Text to use as a label in row n.
; data(n) : Text to display as data in row n.
Note: for any given value for (n), not all combinations of parameters are permitted. The presence of a {{para|header''(n)''}} will cause the corresponding {{para|data''(n)''}} (and {{para|rowclass''(n)''}} {{para|label''(n)''}}, see below) to be ignored; the absence of a {{para|data''(n)''}} will cause the corresponding {{para|label''(n)''}} to be ignored. Valid combinations for any single row are:
* {{para|class''(n)''}} {{para|header''(n)''}}
* {{para|rowclass''(n)''}} {{para|class''(n)''}} {{para|data''(n)''}}
* {{para|rowclass''(n)''}} {{para|label''(n)''}} {{para|class''(n)''}} {{para|data''(n)''}}
See the rendering of header4, label4, and data4 in the [[#Examples|Examples]] section below.
==== Number ranges ====
To allow flexibility when the layout of an infobox is changed, it may be helpful when developing an infobox to use non-contiguous numbers for header and label/data rows. Parameters for new rows can then be inserted in future without having to renumber existing parameters. For example:
<syntaxhighlight lang="wikitext" style="overflow:auto">
| header3 = Section 1
| label5 = Label A
| data5 = Data A
| label7 = Label C
| data7 = Data C
| header10 = Section 2
| label12 = Label D
| data12 = Data D
</syntaxhighlight>{{clear}}
It is also possible to automatically renumber parameter names by using [[User:Frietjes/infoboxgap.js]] or [[Module:IncrementParams]].
There is no upper limit on numbers but there must be at most 50 between each used number.
==== Making data fields optional ====
A row with a label but no data is not displayed. This allows for the easy creation of optional infobox content rows. To make a row optional use a parameter that defaults to an empty string, like so:
<syntaxhighlight lang="wikitext" style="overflow:auto">
| label5 = Population
| data5 = {{{population|}}}
</syntaxhighlight>{{clear}}
This way if an article doesn't define the population parameter in its infobox the row won't be displayed.
For more complex fields with pre-formatted contents that would still be present even if the parameter wasn't set, you can wrap it all in an "#if" statement to make the whole thing vanish when the parameter is not used. For instance, the "#if" statement in the following example reads "#if:the parameter ''mass'' has been supplied |then display it, followed by 'kg'":
<syntaxhighlight lang="wikitext" style="overflow:auto">
| label6 = Mass
| data6 = {{ #if: {{{mass|}}} | {{{mass}}} kg }}
</syntaxhighlight>{{clear}}
For more on #if, see [[meta:ParserFunctions##if:|here]].
==== Hiding headers when all its data fields are empty ====
You can also make headers automatically hide when their section is empty (has no data-row showing).
Consider this situation:
{{Infobox
| title = Example: header with & without data
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Example: header with & without data
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
</syntaxhighlight>{{clear}}
If you want hide the header when no {{para|data''N''}} values are present, use '''{{para|autoheaders|y}}''':
{{Infobox
| title = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
</syntaxhighlight>{{clear}}
So, header1 will be shown if any of item1, item2, or item3 is defined. If none of the three parameters are defined the header won't be shown and no empty row appears before the next visible content.
Note: if the data has empty css elements, like {{para|data|2=<span style="background:yellow;"></span>}}, this will be treated as non-empty (having data).
If {{para|autoheaders|y}} but there are items that you ''do not'' want to trigger a header, place {{para|headerX|_BLANK_}}. This will serve as an empty header and separate it from the subsequent items.
{{Infobox
| title = Example: blank header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = _BLANK_
| label6 = label6 text | data6 = Some value, but does not trigger header1 or show header5
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = _BLANK_
| label6 = label6 text | data6 = Some value, but does not trigger header1 or show header5
}}
</syntaxhighlight>{{clear}}
=== Footer ===
; below : Text to put in the bottom cell. The bottom cell is intended for footnotes, see-also, and other such information.
== Presentation parameters ==
=== Italic titles ===
Titles of articles with infoboxes may be made italic, in line with [[WP:ITALICTITLE]], by passing the <code>italic title</code> parameter.
* Turn on italic titles by passing {{para|italic title|<nowiki>{{{italic title|}}}</nowiki>}} from the infobox.
* Turn off by default (notably because only Latin script may be safely rendered in this style and italic may be needed to distinguish foreign language from local English language only in that script, but would be difficult to read for other scripts) but allow some instances to be made italic by passing {{para|italic title|<nowiki>{{{italic title|no}}}</nowiki>}}
* Do not make any titles italic by not passing the parameter at all.
=== CSS styling ===
{{div col}}
; bodystyle : Applies to the infobox table as a whole
; titlestyle : Applies only to the title caption. Adding a background color is usually inadvisable since the text is rendered "outside" the infobox.
; abovestyle : Applies only to the "above" cell at the top. The default style has font-size:125%; since this cell is usually used for a title, if you want to use the above cell for regular-sized text include "font-size:100%;" in the abovestyle.
; imagestyle : Applies to the cell the image is in. This includes the text of the image caption, but you should set text properties with captionstyle instead of imagestyle in case the caption is moved out of this cell in the future.
; captionstyle : Applies to the text of the image caption.
; rowstyle(n) : This parameter is inserted into the <code>style</code> attribute for the specified row.
; headerstyle : Applies to all header cells
; subheaderstyle : Applies to all subheader cells
; labelstyle : Applies to all label cells
; datastyle : Applies to all data cells
; belowstyle : Applies only to the below cell
{{div col end}}
=== HTML classes and microformats ===
{{div col}}
; bodyclass : This parameter is inserted into the <code>class</code> attribute for the infobox as a whole.
; titleclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''title''' caption.
<!-- currently not implemented in Lua module
; aboverowclass : This parameter is inserted into the <code>class</code> attribute for the complete table row the '''above''' cell is on.
-->
; aboveclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''above''' cell.
; subheaderrowclass(n) : This parameter is inserted into the <code>class</code> attribute for the complete table row the '''subheader''' is on.
; subheaderclass(n) : This parameter is inserted into the <code>class</code> attribute for the infobox's '''subheader'''.
; imagerowclass(n) : These parameters are inserted into the <code>class</code> attribute for the complete table row their respective '''image''' is on.
; imageclass : This parameter is inserted into the <code>class</code> attribute for the '''image'''.
; rowclass(n) : This parameter is inserted into the <code>class</code> attribute for the specified row including the '''label''' and '''data''' cells.
; class(n) : This parameter is inserted into the <code>class</code> attribute for the '''data''' cell of the specified row. If there's no '''data''' cell it has no effect.
<!-- currently not implemented in Lua module
; belowrowclass : This parameter is inserted into the <code>class</code> attribute for the complete table row the '''below''' cell is on.
-->
; belowclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''below''' cell.
{{div col end}}
This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. Multiple class names may be specified, separated by spaces, some of them being used as selectors for custom styling according to a project policy or to the skin selected in user preferences, others being used for microformats.
To flag an infobox as containing [[hCard]] information, for example, add the following parameter:
<syntaxhighlight lang="wikitext" style="overflow:auto">
| bodyclass = vcard
</syntaxhighlight>{{clear}}
And for each row containing a data cell that's part of the vcard, add a corresponding class parameter:
<syntaxhighlight lang="wikitext" style="overflow:auto">
| class1 = fn
| class2 = org
| class3 = tel
</syntaxhighlight>{{clear}}
...and so forth. "above" and "title" can also be given classes, since these are usually used to display the name of the subject of the infobox.
See [[Wikipedia:WikiProject Microformats]] for more information on adding microformat information to Wikipedia, and [[microformat]] for more information on microformats in general.
== Examples ==
Notice how the row doesn't appear in the displayed infobox when a '''label''' is defined without an accompanying '''data''' cell, and how all of them are displayed when a '''header''' is defined on the same row as a '''data''' cell. Also notice that '''subheaders''' are not bold by default like the '''headers''' used to split the main data section, because this role is meant to be for the '''above''' cell :
{{Suppress categories|
{{Infobox
|name = Infobox/doc
|bodystyle =
|titlestyle =
|abovestyle = background:#cfc;
|subheaderstyle =
|title = Test Infobox
|above = Above text
|subheader = Subheader above image
|subheader2 = Second subheader
|imagestyle =
|captionstyle =
|image = [[File:Example-serious.jpg|200px|alt=Example alt text]]
|caption = Caption displayed below File:Example-serious.jpg
|headerstyle = background:#ccf;
|labelstyle = background:#ddf;
|datastyle =
|header1 = Header defined alone
| label1 =
| data1 =
|header2 =
| label2 = Label defined alone does not display (needs data, or is suppressed)
| data2 =
|header3 =
| label3 =
| data3 = Data defined alone
|header4 = All three defined (header, label, data, all with same number)
| label4 = does not display (same number as a header)
| data4 = does not display (same number as a header)
|header5 =
| label5 = Label and data defined (label)
| data5 = Label and data defined (data)
|belowstyle = background:#ddf;
|below = Below text
}}
}}
<syntaxhighlight lang="wikitext">
{{Infobox
|name = Infobox/doc
|bodystyle =
|titlestyle =
|abovestyle = background:#cfc;
|subheaderstyle =
|title = Test Infobox
|above = Above text
|subheader = Subheader above image
|subheader2 = Second subheader
|imagestyle =
|captionstyle =
|image = [[File:Example-serious.jpg|200px|alt=Example alt text]]
|caption = Caption displayed below File:Example-serious.jpg
|headerstyle = background:#ccf;
|labelstyle = background:#ddf;
|datastyle =
|header1 = Header defined alone
| label1 =
| data1 =
|header2 =
| label2 = Label defined alone does not display (needs data, or is suppressed)
| data2 =
|header3 =
| label3 =
| data3 = Data defined alone
|header4 = All three defined (header, label, data, all with same number)
| label4 = does not display (same number as a header)
| data4 = does not display (same number as a header)
|header5 =
| label5 = Label and data defined (label)
| data5 = Label and data defined (data)
|belowstyle = background:#ddf;
|below = Below text
}}
</syntaxhighlight>
For this example, the {{para|bodystyle}} and {{para|labelstyle}} parameters are used to adjust the infobox width and define a default width for the column of labels:
{{Infobox
|name = Infobox/doc
|bodystyle = width:20em
|titlestyle =
|title = Test Infobox
|headerstyle =
|labelstyle = width:33%
|datastyle =
|header1 =
| label1 = Label 1
| data1 = Data 1
|header2 =
| label2 = Label 2
| data2 = Data 2
|header3 =
| label3 = Label 3
| data3 = Data 3
|header4 = Header 4
| label4 =
| data4 =
|header5 =
| label5 = Label 5
| data5 = Data 5: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|belowstyle =
|below = Below text
}}
<syntaxhighlight lang="wikitext">
{{Infobox
|name = Infobox/doc
|bodystyle = width:20em
|titlestyle =
|title = Test Infobox
|headerstyle =
|labelstyle = width:33%
|datastyle =
|header1 =
| label1 = Label 1
| data1 = Data 1
|header2 =
| label2 = Label 2
| data2 = Data 2
|header3 =
| label3 = Label 3
| data3 = Data 3
|header4 = Header 4
| label4 =
| data4 =
|header5 =
| label5 = Label 5
| data5 = Data 5: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|belowstyle =
|below = Below text
}}
</syntaxhighlight>
== Embedding ==
<!--Linked from [[Template:Subinfobox bodystyle/doc]]-->
One infobox template can be embedded into another using the {{para|child}} parameter. This feature can be used to create a modular infobox, or to create better-defined logical sections. Long ago, it was necessary to use embedding in order to create infoboxes with more than 99 rows; but nowadays there's no limit to the number of rows that can be defined in a single instance of <code><nowiki>{{infobox}}</nowiki></code>.
{{Infobox
| title = Top level title
| data1 = {{Infobox | decat = yes | child = yes
| title = First subsection
| label1= Label 1.1
| data1 = Data 1.1
}}
| data2 = {{Infobox | decat = yes | child = yes
|title = Second subsection
| label1= Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Top level title
| data1 = {{Infobox | decat = yes | child = yes
| title = First subsection
| label1= Label 1.1
| data1 = Data 1.1
}}
| data2 = {{Infobox | decat = yes | child = yes
|title = Second subsection
| label1= Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
</syntaxhighlight>{{clear}}
Note, in the examples above, the child infobox is placed in a <code>data</code> field, not a <code>header</code> field. Notice that the section subheadings are not in bold font if bolding is not explicitly specified. To obtain bold section headings, place the child infobox in a '''header''' field (but not in a '''label''' field because it would not be displayed!), either using
{{Infobox
| title = Top level title
| header1 = {{Infobox | decat = yes | child = yes
| title = First subsection
| label1= Label 1.1
| data1 = Data 1.1
}}
| header2 = {{Infobox | decat = yes | child = yes
| title = Second subsection
| label1= Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Top level title
| header1 = {{Infobox | decat = yes | child = yes
| title = First subsection
| label1= Label 1.1
| data1 = Data 1.1
}}
| header2 = {{Infobox | decat = yes | child = yes
| title = Second subsection
| label1= Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
</syntaxhighlight>{{clear}}
or,
{{Infobox
| title = Top level title
| header1 = First subsection
{{Infobox | decat = yes | child = yes
| label1 = Label 1.1
| data1 = Data 1.1
}}
| header2 = Second subsection
{{Infobox | decat = yes | child = yes
| label1 = Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| title = Top level title
| header1 = First subsection
{{Infobox | decat = yes | child = yes
| label1 = Label 1.1
| data1 = Data 1.1
}}
| header2 = Second subsection
{{Infobox | decat = yes | child = yes
| label1 = Label 2.1
| data1 = Data 2.1
}}
| belowstyle =
| below = Below text
}}
</syntaxhighlight>{{clear}}
Note that omitting the {{para|title}} parameter, and not including any text preceding the embedded infobox, may result in spurious blank table rows, creating gaps in the visual presentation. The garbage output can be suppressed using {{para|rowstyleN|display: none}}, replacing N with the data/header number.
[[Wikipedia:WikiProject Infoboxes/embed]] includes some links to Wikipedia articles which include infoboxes embedded within other infoboxes.
== Subboxes ==
An alternative method for embedding is to use {{para|subbox|yes}}, which removes the outer border from the infobox, but preserves the interior structure. One feature of this approach is that the parent and child boxes need not have the same structure, and the label and data fields are not aligned between the parent and child boxes because they are not in the same parent table.
{{Infobox
| headerstyle = background-color:#eee;
| labelstyle = background-color:#eee;
| header1 = Main 1
| header2 = Main 2
| data3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| data4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| label5 = Label 5 | data5 = Data 5
| header6 = Main 6
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| headerstyle = background-color:#eee;
| labelstyle = background-color:#eee;
| header1 = Main 1
| header2 = Main 2
| data3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| data4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| label5 = Label 5 | data5 = Data 5
| header6 = Main 6
}}
</syntaxhighlight>{{clear}}
Similar embedding techniques may be used within content parameters of some other templates generating tables (such as [[:Template:Sidebar|Sidebar]]) :
{{Sidebar
| navbar = off
| headingstyle = background-color:#eee;
| heading1 = Heading 1
| heading2 = Heading 2
| content3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| content4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| heading5 = Heading 5
}}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Sidebar
| navbar = off
| headingstyle = background-color:#eee;
| heading1 = Heading 1
| heading2 = Heading 2
| content3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| content4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| heading5 = Heading 5
}}
</syntaxhighlight>{{clear}}
Note that the default padding of the parent data cell containing each subbox is still visible, so the subboxes are slightly narrower than the parent box and there's a higher vertical spacing between standard cells of the parent box than between cells of distinct subboxes.
== Controlling line-breaking in embedded bulletless lists ==
Template {{tlx|nbsp}} may be used with {{tlx|wbr}} and {{tlx|nowrap}} to control line-breaking in bulletless lists embedded in infoboxes (e.g. cast list in {{tlx|Infobox film}}), to prevent wrapped long entries from being confused with multiple entries. See [[Template:Wbr/doc#Controlling line-breaking in infoboxes]] for details.
== Full blank syntax ==
(Note: there is no limit to the number of possible rows; only 20 are given below since infoboxes larger than that will be relatively rare. Just extend the numbering as needed. The microformat "class" parameters are also omitted as they are not commonly used.)
<syntaxhighlight lang="wikitext" style="overflow:auto">
{{Infobox
| name = {{subst:PAGENAME}}
| child = {{{child|}}}
| subbox = {{{subbox|}}}
| italic title = {{{italic title|no}}}
| templatestyles =
| child templatestyles =
| grandchild templatestyles =
| bodystyle =
| titlestyle =
| abovestyle =
| subheaderstyle =
| title =
| above =
| subheader =
| imagestyle =
| captionstyle =
| image =
| caption =
| image2 =
| caption2 =
| headerstyle =
| labelstyle =
| datastyle =
| header1 =
| label1 =
| data1 =
| header2 =
| label2 =
| data2 =
| header3 =
| label3 =
| data3 =
| header4 =
| label4 =
| data4 =
| header5 =
| label5 =
| data5 =
| header6 =
| label6 =
| data6 =
| header7 =
| label7 =
| data7 =
| header8 =
| label8 =
| data8 =
| header9 =
| label9 =
| data9 =
| header10 =
| label10 =
| data10 =
| header11 =
| label11 =
| data11 =
| header12 =
| label12 =
| data12 =
| header13 =
| label13 =
| data13 =
| header14 =
| label14 =
| data14 =
| header15 =
| label15 =
| data15 =
| header16 =
| label16 =
| data16 =
| header17 =
| label17 =
| data17 =
| header18 =
| label18 =
| data18 =
| header19 =
| label19 =
| data19 =
| header20 =
| label20 =
| data20 =
| belowstyle =
| below =
}}
</syntaxhighlight>{{clear}}
{{Help:Infobox/user style}}
== Porting to other MediaWikis ==
The infobox template requires the [[:mw:Extension:Scribunto|Scribunto]] and [[:mw:Extension:TemplateStyles|TemplateStyles]] extensions. [[Wikipedia:WikiProject Transwiki|WikiProject Transwiki]] has a version of this template that has been modified to work on other MediaWikis.
== TemplateData ==
{{TemplateData header}}
<templatedata>
{
"description": "This template is intended as a meta template, a template used for constructing other templates. In general, it is not meant for use directly in an article but can be used on a one-off basis if required.",
"format": "{{_\n| ________________ = _\n}}\n",
"params": {
"title": {
"label": "Title",
"description": "Title displayed above the infobox",
"type": "string",
"suggested": true
},
"image": {
"label": "Image",
"description": "Image illustrating the topic. Use full image syntax.",
"type": "content",
"suggested": true,
"example": "[[File:example.png|200px|alt=Example alt text]]"
},
"caption": {
"label": "Caption",
"description": "caption for the image",
"type": "content",
"suggested": true
}
},
"paramOrder": [
"title",
"image",
"caption"
]
}
</templatedata>
==Tracking categories==
* {{Category link with count|Articles with missing Wikidata information}}
* {{Category link with count|Articles using infobox templates with no data rows}}
* {{Category link with count|Pages using embedded infobox templates with the title parameter}}
==See also==
* [[Module:Infobox]], the [[WP:LUA|Lua]] module on which this template is based
* [[Module:Check for unknown parameters]]
* {{tl|Infobox3cols}}
* {{tl|Navbox}} and {{tl|Sidebar}}
* [[Wikipedia:List of infoboxes|List of infoboxes]]
* [[:Module:InfoboxImage]]
<includeonly>{{Sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Infobox templates| ]]
[[Category:Wikipedia metatemplates|Infobox]]
[[Category:Templates generating microformats]]
[[Category:Templates that add a tracking category]]
[[Category:Templates based on the Infobox Lua module]]
}}</includeonly>
b7ba187ea76ee960bbe295ad01c44c646eaedadb
Help:Infobox/user style
12
72
148
147
2023-10-01T08:21:29Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{{heading|
==Infoboxes and user style ==
}}}
Users can have [[WP:User style|user CSS]] that hides<!--, moves, or makes collapsible--> any infoboxes in their own browsers.
To hide all infoboxes, add the following to [[Special:MyPage/common.css]] (for all [[WP:Skin|skins]], or [[Special:MyPage/skin.css]] for just the current skin), on a line by itself:
<syntaxhighlight lang="css">div.mw-parser-output .infobox { display: none; }</syntaxhighlight>
Alternatively, you can add the following code to [[Special:MyPage/common.js|your common.js]] or into a browser user script that is executed by an extension like [[Greasemonkey]]:
<syntaxhighlight lang="js">$('.infobox').hide();</syntaxhighlight>
Be aware that although{{#if:{{{guideline|}}}||, per [[WP:Manual of Style/Infoboxes]],}} all information in an infobox ideally should also be found in the main body of an article, there isn't perfect compliance with this guideline. For example, the full taxonomic hierarchy in {{tlx|Taxobox}}, and the OMIM and other medical database codes of {{tlx|Infobox disease}} are often not found in the main article content. The infobox is also often the location of the most significant, even only, image in an article. There is a userscript which removes infoboxes but moves the images contained to separate thumbnails: [[User:Maddy from Celeste/disinfobox.js]].<!--
Needs Special:Mypage/common.js options for:
* Making infoboxes collapsible
** Making them auto-collapsed
* Moving infoboxes to bottom of page
--><noinclude>
{{Documentation|content=
This documentation snippet is transcluded at [[Help:Infobox]], [[Template:Infobox/doc]], [[WP:Customisation#Hiding specific messages]], [[Help:User style]], [[WP:Manual of Style/Infoboxes]], and other places where this information is relevant.
As a template, this snippet takes a {{para|heading}} parameter to replace the level-2 <code>==Infoboxes and user style==</code> section heading code, as needed. E.g., for a <code>=== ... ===</code> level-3 heading: <code><nowiki>heading={{=}}{{=}}{{=}}Infoboxes and user style{{=}}{{=}}{{=}}</nowiki></code>
}}
</noinclude>
ba4dac68eb2bdc49a32f2a11b9afd52381bf06b5
Module:Message box/ombox.css
828
73
150
149
2023-10-01T08:21:30Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp|small=y}} */
.ombox {
margin: 4px 0;
border-collapse: collapse;
border: 1px solid #a2a9b1; /* Default "notice" gray */
background-color: #f8f9fa;
box-sizing: border-box;
}
/* For the "small=yes" option. */
.ombox.mbox-small {
font-size: 88%;
line-height: 1.25em;
}
.ombox-speedy {
border: 2px solid #b32424; /* Red */
background-color: #fee7e6; /* Pink */
}
.ombox-delete {
border: 2px solid #b32424; /* Red */
}
.ombox-content {
border: 1px solid #f28500; /* Orange */
}
.ombox-style {
border: 1px solid #fc3; /* Yellow */
}
.ombox-move {
border: 1px solid #9932cc; /* Purple */
}
.ombox-protection {
border: 2px solid #a2a9b1; /* Gray-gold */
}
.ombox .mbox-text {
border: none;
/* @noflip */
padding: 0.25em 0.9em;
width: 100%;
}
.ombox .mbox-image {
border: none;
/* @noflip */
padding: 2px 0 2px 0.9em;
text-align: center;
}
.ombox .mbox-imageright {
border: none;
/* @noflip */
padding: 2px 0.9em 2px 0;
text-align: center;
}
/* An empty narrow cell */
.ombox .mbox-empty-cell {
border: none;
padding: 0;
width: 1px;
}
.ombox .mbox-invalid-type {
text-align: center;
}
@media (min-width: 720px) {
.ombox {
margin: 4px 10%;
}
.ombox.mbox-small {
/* @noflip */
clear: right;
/* @noflip */
float: right;
/* @noflip */
margin: 4px 0 4px 1em;
width: 238px;
}
}
8fe3df4bb607e699eab2dbd23bd4a1a446391002
Template:Hlist/styles.css
10
74
152
151
2023-10-01T08:21:30Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp-protected|reason=match parent|small=yes}} */
/*
* hlist styles are defined in core and Minerva and differ in Minerva. The
* current definitions here (2023-01-01) are sufficient to override Minerva
* without use of the hlist-separated class. The most problematic styles were
* related to margin, padding, and the bullet. Check files listed at
* [[MediaWiki talk:Common.css/to do#hlist-separated]]
*/
/*
* TODO: When the majority of readership supports it (or some beautiful world
* in which grade C support is above the minimum threshold), use :is()
*/
.hlist dl,
.hlist ol,
.hlist ul {
margin: 0;
padding: 0;
}
/* Display list items inline */
.hlist dd,
.hlist dt,
.hlist li {
/*
* don't trust the note that says margin doesn't work with inline
* removing margin: 0 makes dds have margins again
* We also want to reset margin-right in Minerva
*/
margin: 0;
display: inline;
}
/* Display requested top-level lists inline */
.hlist.inline,
.hlist.inline dl,
.hlist.inline ol,
.hlist.inline ul,
/* Display nested lists inline */
.hlist dl dl,
.hlist dl ol,
.hlist dl ul,
.hlist ol dl,
.hlist ol ol,
.hlist ol ul,
.hlist ul dl,
.hlist ul ol,
.hlist ul ul {
display: inline;
}
/* Hide empty list items */
.hlist .mw-empty-li {
display: none;
}
/* TODO: :not() can maybe be used here to remove the later rule. naive test
* seems to work. more testing needed. like so:
*.hlist dt:not(:last-child)::after {
* content: ": ";
*}
*.hlist dd:not(:last-child)::after,
*.hlist li:not(:last-child)::after {
* content: " · ";
* font-weight: bold;
*}
*/
/* Generate interpuncts */
.hlist dt::after {
content: ": ";
}
.hlist dd::after,
.hlist li::after {
content: " · ";
font-weight: bold;
}
.hlist dd:last-child::after,
.hlist dt:last-child::after,
.hlist li:last-child::after {
content: none;
}
/* Add parentheses around nested lists */
.hlist dd dd:first-child::before,
.hlist dd dt:first-child::before,
.hlist dd li:first-child::before,
.hlist dt dd:first-child::before,
.hlist dt dt:first-child::before,
.hlist dt li:first-child::before,
.hlist li dd:first-child::before,
.hlist li dt:first-child::before,
.hlist li li:first-child::before {
content: " (";
font-weight: normal;
}
.hlist dd dd:last-child::after,
.hlist dd dt:last-child::after,
.hlist dd li:last-child::after,
.hlist dt dd:last-child::after,
.hlist dt dt:last-child::after,
.hlist dt li:last-child::after,
.hlist li dd:last-child::after,
.hlist li dt:last-child::after,
.hlist li li:last-child::after {
content: ")";
font-weight: normal;
}
/* Put ordinals in front of ordered list items */
.hlist ol {
counter-reset: listitem;
}
.hlist ol > li {
counter-increment: listitem;
}
.hlist ol > li::before {
content: " " counter(listitem) "\a0";
}
.hlist dd ol > li:first-child::before,
.hlist dt ol > li:first-child::before,
.hlist li ol > li:first-child::before {
content: " (" counter(listitem) "\a0";
}
8c9dd9c9c00f30eead17fe10f51d183333e81f33
Template:Ombox
10
75
154
153
2023-10-01T08:21:31Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:Message box|ombox}}<noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->
</noinclude>
0e54065432d540737b9e56c4e3a8e7f74d4534ea
Module:TNT
828
76
156
155
2023-10-01T08:21:32Z
Reverie
2
1 revision imported
Scribunto
text/plain
--
-- INTRO: (!!! DO NOT RENAME THIS PAGE !!!)
-- This module allows any template or module to be copy/pasted between
-- wikis without any translation changes. All translation text is stored
-- in the global Data:*.tab pages on Commons, and used everywhere.
--
-- SEE: https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules
--
-- ATTENTION:
-- Please do NOT rename this module - it has to be identical on all wikis.
-- This code is maintained at https://www.mediawiki.org/wiki/Module:TNT
-- Please do not modify it anywhere else, as it may get copied and override your changes.
-- Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT
--
-- DESCRIPTION:
-- The "msg" function uses a Commons dataset to translate a message
-- with a given key (e.g. source-table), plus optional arguments
-- to the wiki markup in the current content language.
-- Use lang=xx to set language. Example:
--
-- {{#invoke:TNT | msg
-- | I18n/Template:Graphs.tab <!-- https://commons.wikimedia.org/wiki/Data:I18n/Template:Graphs.tab -->
-- | source-table <!-- uses a translation message with id = "source-table" -->
-- | param1 }} <!-- optional parameter -->
--
--
-- The "doc" function will generate the <templatedata> parameter documentation for templates.
-- This way all template parameters can be stored and localized in a single Commons dataset.
-- NOTE: "doc" assumes that all documentation is located in Data:Templatedata/* on Commons.
--
-- {{#invoke:TNT | doc | Graph:Lines }}
-- uses https://commons.wikimedia.org/wiki/Data:Templatedata/Graph:Lines.tab
-- if the current page is Template:Graph:Lines/doc
--
local p = {}
local i18nDataset = 'I18n/Module:TNT.tab'
-- Forward declaration of the local functions
local sanitizeDataset, loadData, link, formatMessage
function p.msg(frame)
local dataset, id
local params = {}
local lang = nil
for k, v in pairs(frame.args) do
if k == 1 then
dataset = mw.text.trim(v)
elseif k == 2 then
id = mw.text.trim(v)
elseif type(k) == 'number' then
table.insert(params, mw.text.trim(v))
elseif k == 'lang' and v ~= '_' then
lang = mw.text.trim(v)
end
end
return formatMessage(dataset, id, params, lang)
end
-- Identical to p.msg() above, but used from other lua modules
-- Parameters: name of dataset, message key, optional arguments
-- Example with 2 params: format('I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset')
function p.format(dataset, key, ...)
local checkType = require('libraryUtil').checkType
checkType('format', 1, dataset, 'string')
checkType('format', 2, key, 'string')
return formatMessage(dataset, key, {...})
end
-- Identical to p.msg() above, but used from other lua modules with the language param
-- Parameters: language code, name of dataset, message key, optional arguments
-- Example with 2 params: formatInLanguage('es', I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset')
function p.formatInLanguage(lang, dataset, key, ...)
local checkType = require('libraryUtil').checkType
checkType('formatInLanguage', 1, lang, 'string')
checkType('formatInLanguage', 2, dataset, 'string')
checkType('formatInLanguage', 3, key, 'string')
return formatMessage(dataset, key, {...}, lang)
end
-- Obsolete function that adds a 'c:' prefix to the first param.
-- "Sandbox/Sample.tab" -> 'c:Data:Sandbox/Sample.tab'
function p.link(frame)
return link(frame.args[1])
end
function p.doc(frame)
local dataset = 'Templatedata/' .. sanitizeDataset(frame.args[1])
return frame:extensionTag('templatedata', p.getTemplateData(dataset)) ..
formatMessage(i18nDataset, 'edit_doc', {link(dataset)})
end
function p.getTemplateData(dataset)
-- TODO: add '_' parameter once lua starts reindexing properly for "all" languages
local data = loadData(dataset)
local names = {}
for _, field in pairs(data.schema.fields) do
table.insert(names, field.name)
end
local params = {}
local paramOrder = {}
for _, row in pairs(data.data) do
local newVal = {}
local name = nil
for pos, val in pairs(row) do
local columnName = names[pos]
if columnName == 'name' then
name = val
else
newVal[columnName] = val
end
end
if name then
params[name] = newVal
table.insert(paramOrder, name)
end
end
-- Work around json encoding treating {"1":{...}} as an [{...}]
params['zzz123']=''
local json = mw.text.jsonEncode({
params=params,
paramOrder=paramOrder,
description=data.description
})
json = string.gsub(json,'"zzz123":"",?', "")
return json
end
-- Local functions
sanitizeDataset = function(dataset)
if not dataset then
return nil
end
dataset = mw.text.trim(dataset)
if dataset == '' then
return nil
elseif string.sub(dataset,-4) ~= '.tab' then
return dataset .. '.tab'
else
return dataset
end
end
loadData = function(dataset, lang)
dataset = sanitizeDataset(dataset)
if not dataset then
error(formatMessage(i18nDataset, 'error_no_dataset', {}))
end
-- Give helpful error to thirdparties who try and copy this module.
if not mw.ext or not mw.ext.data or not mw.ext.data.get then
error('Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:' .. dataset)
end
local data = mw.ext.data.get(dataset, lang)
if data == false then
if dataset == i18nDataset then
-- Prevent cyclical calls
error('Missing Commons dataset ' .. i18nDataset)
else
error(formatMessage(i18nDataset, 'error_bad_dataset', {link(dataset)}))
end
end
return data
end
-- Given a dataset name, convert it to a title with the 'commons:data:' prefix
link = function(dataset)
return 'c:Data:' .. mw.text.trim(dataset or '')
end
formatMessage = function(dataset, key, params, lang)
for _, row in pairs(loadData(dataset, lang).data) do
local id, msg = unpack(row)
if id == key then
local result = mw.message.newRawMessage(msg, unpack(params or {}))
return result:plain()
end
end
if dataset == i18nDataset then
-- Prevent cyclical calls
error('Invalid message key "' .. key .. '"')
else
error(formatMessage(i18nDataset, 'error_bad_msgkey', {key, link(dataset)}))
end
end
return p
9d0d10e54abd232c806dcabccaf03e52858634a1
Template:Clc
10
77
158
157
2023-10-01T08:21:32Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Category link with count]]
02280e2ab57b544236e11f913e3759c5781ca9d5
Template:Module other
10
78
160
159
2023-10-01T08:21:33Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#switch:
<!--If no or empty "demospace" parameter then detect namespace-->
{{#if:{{{demospace|}}}
| {{lc: {{{demospace}}} }} <!--Use lower case "demospace"-->
| {{#ifeq:{{NAMESPACE}}|{{ns:Module}}
| module
| other
}}
}}
| module = {{{1|}}}
| other
| #default = {{{2|}}}
}}<!--End switch--><noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
503694836c1b07142e63fd35d8be69ec8bb9ffe7
Template:Module rating
10
79
162
161
2023-10-01T08:21:33Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#ifeq:{{SUBPAGENAME}}|doc|<!--do not show protection level of the module on the doc page, use the second and optionally third parameter if the doc page is also protected -->{{#if:{{{2|}}}|{{Pp|{{{2}}}|action={{{3|}}}}}}}|{{Module other|{{ombox
| type = notice
| image = {{#switch: {{{1|}}}
| pre-alpha | prealpha | pa = [[File:Ambox warning blue construction.svg|40x40px|link=|alt=Pre-alpha]]
| alpha | a = [[File:Alpha lowercase.svg|26x26px|link=|alt=Alpha]]
| beta | b = [[File:Greek lc beta.svg|40x40px|link=|alt=Beta]]
| release | r | general | g = [[File:Green check.svg|40x40px|link=|alt=Ready for use]]
| protected | protect | p = [[File:{{#switch:{{#invoke:Effective protection level|edit|{{#switch:{{SUBPAGENAME}}|doc|sandbox={{FULLBASEPAGENAME}}|{{FULLPAGENAME}}}}}}|autoconfirmed=Semi|extendedconfirmed=Extended|accountcreator|templateeditor=Template|#default=Full}}-protection-shackle.svg|40x40px|link=|alt=Protected]]
| semiprotected | semiprotect | semi =[[File:Semi-protection-shackle.svg|40x40px|link=|alt=Semi-protected]]
}}
| style =
| textstyle =
| text = {{#switch: {{{1|}}}
| pre-alpha | prealpha | pa = This module is rated as [[:Category:Modules in pre-alpha development|pre-alpha]]. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules in pre-alpha development|{{PAGENAME}}]] }}
}}
| alpha | a = This module is rated as [[:Category:Modules in alpha|alpha]]. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules in alpha|{{PAGENAME}}]] }}
}}
| beta | b = This module is rated as [[:Category:Modules in beta|beta]], and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules in beta|{{PAGENAME}}]] }}
}}
| release | r | general | g = This module is rated as [[:Category:Modules for general use|ready for general use]]. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by [[Wikipedia:Template sandbox and test cases|sandbox testing]] rather than repeated trial-and-error editing.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules for general use|{{PAGENAME}}]] }}
}}
| protected | protect | p = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[Wikipedia:Protection policy|protected]] from editing.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules subject to page protection|{{PAGENAME}}]] }}
}}
| semiprotected | semiprotect | semi = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[WP:SEMI|semi-protected]] from editing.<!--
-->{{#switch: {{SUBPAGENAME}}|doc|sandbox=<!-- No category for /doc or /sandbox subpages -->
| {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | [[Category:Modules subject to page protection|{{PAGENAME}}]] }}
}}
| #default = {{error|Module rating is invalid or not specified.}}
}}
}}|{{error|Error: {{tl|Module rating}} must be placed in the Module namespace.}} [[Category:Pages with templates in the wrong namespace]]|demospace={{{demospace|<noinclude>module</noinclude>}}}}}}}</includeonly><noinclude>
{{module rating|release|nocat=true|demospace=module}}
{{documentation}}
<!-- Categories go on the /doc subpage, and interwikis go in Wikidata. -->
</noinclude>
bbd244b3ea2e13ec4c1c810ae44f2f3789a93efc
Template:Uses TemplateStyles
10
80
164
163
2023-10-01T08:21:34Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#invoke:Uses TemplateStyles|main}}</includeonly><noinclude>{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
60f2fc73c4d69b292455879f9fcb3c68f6c63c2a
Module:Uses TemplateStyles
828
81
166
165
2023-10-01T08:21:34Z
Reverie
2
1 revision imported
Scribunto
text/plain
local yesno = require('Module:Yesno')
local mList = require('Module:List')
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')
local TNT = require('Module:TNT')
local p = {}
local function format(msg, ...)
return TNT.format('I18n/Uses TemplateStyles', msg, ...)
end
local function getConfig()
return mw.loadData('Module:Uses TemplateStyles/config')
end
local function renderBox(tStyles)
local boxArgs = {
type = 'notice',
small = true,
image = string.format('[[File:Farm-Fresh css add.svg|32px|alt=%s]]', format('logo-alt'))
}
if #tStyles < 1 then
boxArgs.text = string.format('<strong class="error">%s</strong>', format('error-emptylist'))
else
local cfg = getConfig()
local tStylesLinks = {}
for i, ts in ipairs(tStyles) do
local link = string.format('[[:%s]]', ts)
local sandboxLink = nil
local tsTitle = mw.title.new(ts)
if tsTitle and cfg['sandbox_title'] then
local tsSandboxTitle = mw.title.new(string.format(
'%s:%s/%s/%s', tsTitle.nsText, tsTitle.baseText, cfg['sandbox_title'], tsTitle.subpageText))
if tsSandboxTitle and tsSandboxTitle.exists then
sandboxLink = format('sandboxlink', link, ':' .. tsSandboxTitle.prefixedText)
end
end
tStylesLinks[i] = sandboxLink or link
end
local tStylesList = mList.makeList('bulleted', tStylesLinks)
boxArgs.text = format(
mw.title.getCurrentTitle():inNamespaces(828,829) and 'header-module' or 'header-template') ..
'\n' .. tStylesList
end
return mMessageBox.main('mbox', boxArgs)
end
local function renderTrackingCategories(args, tStyles, titleObj)
if yesno(args.nocat) then
return ''
end
local cfg = getConfig()
local cats = {}
-- Error category
if #tStyles < 1 and cfg['error_category'] then
cats[#cats + 1] = cfg['error_category']
end
-- TemplateStyles category
titleObj = titleObj or mw.title.getCurrentTitle()
if (titleObj.namespace == 10 or titleObj.namespace == 828)
and not cfg['subpage_blacklist'][titleObj.subpageText]
then
local category = args.category or cfg['default_category']
if category then
cats[#cats + 1] = category
end
if not yesno(args.noprotcat) and (cfg['protection_conflict_category'] or cfg['padlock_pattern']) then
local currentProt = titleObj.protectionLevels["edit"] and titleObj.protectionLevels["edit"][1] or nil
local addedLevelCat = false
local addedPadlockCat = false
for i, ts in ipairs(tStyles) do
local tsTitleObj = mw.title.new(ts)
local tsProt = tsTitleObj.protectionLevels["edit"] and tsTitleObj.protectionLevels["edit"][1] or nil
if cfg['padlock_pattern'] and tsProt and not addedPadlockCat then
local content = tsTitleObj:getContent()
if not content:find(cfg['padlock_pattern']) then
cats[#cats + 1] = cfg['missing_padlock_category']
addedPadlockCat = true
end
end
if cfg['protection_conflict_category'] and currentProt and tsProt ~= currentProt and not addedLevelCat then
currentProt = cfg['protection_hierarchy'][currentProt] or 0
tsProt = cfg['protection_hierarchy'][tsProt] or 0
if tsProt < currentProt then
addedLevelCat = true
cats[#cats + 1] = cfg['protection_conflict_category']
end
end
end
end
end
for i, cat in ipairs(cats) do
cats[i] = string.format('[[Category:%s]]', cat)
end
return table.concat(cats)
end
function p._main(args, cfg)
local tStyles = mTableTools.compressSparseArray(args)
local box = renderBox(tStyles)
local trackingCategories = renderTrackingCategories(args, tStyles)
return box .. trackingCategories
end
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('^%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
return p
71ca57c37849f38e3c5ee30061bdae730963e48e
Module:Uses TemplateStyles/config
828
82
168
167
2023-10-01T08:21:35Z
Reverie
2
1 revision imported
Scribunto
text/plain
local cfg = {} -- Don’t touch this line.
-- Subpage blacklist: these subpages will not be categorized (except for the
-- error category, which is always added if there is an error).
-- For example “Template:Foo/doc” matches the `doc = true` rule, so it will have
-- no categories. “Template:Foo” and “Template:Foo/documentation” match no rules,
-- so they *will* have categories. All rules should be in the
-- ['<subpage name>'] = true,
-- format.
cfg['subpage_blacklist'] = {
['doc'] = true,
['sandbox'] = true,
['sandbox2'] = true,
['testcases'] = true,
}
-- Sandbox title: if the stylesheet’s title is <template>/<stylesheet>.css, the
-- stylesheet’s sandbox is expected to be at <template>/<sandbox_title>/<stylesheet>.css
-- Set to nil to disable sandbox links.
cfg['sandbox_title'] = 'sandbox'
-- Error category: this category is added if the module call contains errors
-- (e.g. no stylesheet listed). A category name without namespace, or nil
-- to disable categorization (not recommended).
cfg['error_category'] = 'Uses TemplateStyles templates with errors'
-- Default category: this category is added if no custom category is specified
-- in module/template call. A category name without namespace, or nil
-- to disable categorization.
cfg['default_category'] = 'Templates using TemplateStyles'
-- Protection conflict category: this category is added if the protection level
-- of any stylesheet is lower than the protection level of the template. A category name
-- without namespace, or nil to disable categorization (not recommended).
cfg['protection_conflict_category'] = 'Templates using TemplateStyles with a different protection level'
-- Hierarchy of protection levels, used to determine whether one protection level is lower
-- than another and thus should populate protection_conflict_category. No protection is treated as zero
cfg['protection_hierarchy'] = {
autoconfirmed = 1,
extendedconfirmed = 2,
templateeditor = 3,
sysop = 4
}
-- Padlock pattern: Lua pattern to search on protected stylesheets for, or nil
-- to disable padlock check.
cfg['padlock_pattern'] = '{{pp-'
-- Missing padlock category: this category is added if a protected stylesheet
-- doesn’t contain any padlock template (specified by the above Lua pattern).
-- A category name without namespace (no nil allowed) if the pattern is not nil,
-- unused (and thus may be nil) otherwise.
cfg['missing_padlock_category'] = 'Templates using TemplateStyles without padlocks'
return cfg -- Don’t touch this line.
58e7a37c44f6ea3f6b8af54a559d696cc7256493
Module:Infobox/doc
828
83
170
169
2023-10-01T08:21:35Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{High-use|3308957|all-pages = yes}}
{{module rating|protected}}
{{Lua|Module:Navbar|Module:Italic title}}
{{Uses TemplateStyles|Module:Infobox/styles.css|Template:Hlist/styles.css|Template:Plainlist/styles.css}}
'''Module:Infobox''' is a [[WP:Module|module]] that implements the {{tl|Infobox}} template. Please see the template page for usage instructions.
== Tracking categories ==
* {{clc|Pages using infobox templates with ignored data cells}}
* {{clc|Articles using infobox templates with no data rows}}
* {{clc|Pages using embedded infobox templates with the title parameter}}
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
[[Category:Modules that add a tracking category]]
[[Category:Wikipedia infoboxes]]
[[Category:Infobox modules]]
[[Category:Modules that check for strip markers]]
}}</includeonly>
936ad219eb263a6f3293d62f667bd7b5db1059c1
Template:Plainlist/styles.css
10
84
172
171
2023-10-01T08:21:35Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp-template|small=yes}} */
.plainlist ol,
.plainlist ul {
line-height: inherit;
list-style: none;
margin: 0;
padding: 0; /* Reset Minerva default */
}
.plainlist ol li,
.plainlist ul li {
margin-bottom: 0;
}
51706efa229ff8794c0d94f260a208e7c5e6ec30
Template:Ship Infobox
10
85
173
2023-10-01T08:29:43Z
Reverie
2
Created page with "{{Infobox |Hide header= |Ship country= |Ship flag= |Ship name= |Ship owner= |Ship ordered= |Ship builder= |Ship original cost= |Ship laid down= |Ship launched= |Ship acquired= |Ship commissioned= |Ship decommissioned= |Ship in service= |Ship out of service= |Ship renamed= |Ship stricken= |Ship reinstated= |Ship honours= |Ship honors= |Ship captured= |Ship fate= |Ship status= |Ship notes= }}"
wikitext
text/x-wiki
{{Infobox
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship owner=
|Ship ordered=
|Ship builder=
|Ship original cost=
|Ship laid down=
|Ship launched=
|Ship acquired=
|Ship commissioned=
|Ship decommissioned=
|Ship in service=
|Ship out of service=
|Ship renamed=
|Ship stricken=
|Ship reinstated=
|Ship honours=
|Ship honors=
|Ship captured=
|Ship fate=
|Ship status=
|Ship notes=
}}
9fff9da31c346fd8e1504ebdbbe81e98ac7b4ad1
174
173
2023-10-01T08:31:04Z
Reverie
2
Replaced content with "Test"
wikitext
text/x-wiki
Test
640ab2bae07bedc4c163f679a746f7ab7fb5d1fa
Template:Infobox ship career
10
86
176
175
2023-10-01T08:32:35Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<noinclude>{{Being deleted|2022 April 30|Template:Infobox ship begin|merge= Template:Infobox ship}}</noinclude><includeonly>{{#invoke:WPSHIPS utilities|infobox_ship_career}}</includeonly><noinclude>{{Documentation}}</noinclude>
2eae0adc486cfbc7dc90adf926736348da972150
Template:Mbox
10
87
178
177
2023-10-01T08:32:37Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:Message box|mbox}}<noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! -->
</noinclude>
5bfb2becf8bed35974b47e3ff8660dc14bee40c7
Module:Convert
828
88
180
179
2023-10-01T08:32:38Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- Convert a value from one unit of measurement to another.
-- Example: {{convert|123|lb|kg}} --> 123 pounds (56 kg)
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
local MINUS = '−' -- Unicode U+2212 MINUS SIGN (UTF-8: e2 88 92)
local abs = math.abs
local floor = math.floor
local format = string.format
local log10 = math.log10
local ustring = mw.ustring
local ulen = ustring.len
local usub = ustring.sub
-- Configuration options to keep magic values in one location.
-- Conversion data and message text are defined in separate modules.
local config, maxsigfig
local numdot -- must be '.' or ',' or a character which works in a regex
local numsep, numsep_remove, numsep_remove2
local data_code, all_units
local text_code
local varname -- can be a code to use variable names that depend on value
local from_en_table -- to translate an output string of en digits to local language
local to_en_table -- to translate an input string of digits in local language to en
-- Use translation_table in convert/text to change the following.
local en_default -- true uses lang=en unless convert has lang=local or local digits
local group_method = 3 -- code for how many digits are in a group
local per_word = 'per' -- for units like "liters per kilometer"
local plural_suffix = 's' -- only other useful value is probably '' to disable plural unit names
local omitsep -- true to omit separator before local symbol/name
-- All units should be defined in the data module. However, to cater for quick changes
-- and experiments, any unknown unit is looked up in an extra data module, if it exists.
-- That module would be transcluded in only a small number of pages, so there should be
-- little server overhead from making changes, and changes should propagate quickly.
local extra_module -- name of module with extra units
local extra_units -- nil or table of extra units from extra_module
-- Some options in the invoking template can set variables used later in the module.
local currency_text -- for a user-defined currency symbol: {{convert|12|$/ha|$=€}} (euro replaces dollar)
local function from_en(text)
-- Input is a string representing a number in en digits with '.' decimal mark,
-- without digit grouping (which is done just after calling this).
-- Return the translation of the string with numdot and digits in local language.
if numdot ~= '.' then
text = text:gsub('%.', numdot)
end
if from_en_table then
text = text:gsub('%d', from_en_table)
end
return text
end
local function to_en(text)
-- Input is a string representing a number in the local language with
-- an optional numdot decimal mark and numsep digit grouping.
-- Return the translation of the string with '.' mark and en digits,
-- and no separators (they have to be removed here to handle cases like
-- numsep = '.' and numdot = ',' with input "1.234.567,8").
if to_en_table then
text = ustring.gsub(text, '%d', to_en_table)
end
if numsep_remove then
text = text:gsub(numsep_remove, '')
end
if numsep_remove2 then
text = text:gsub(numsep_remove2, '')
end
if numdot ~= '.' then
text = text:gsub(numdot, '.')
end
return text
end
local function decimal_mark(text)
-- Return ',' if text probably is using comma for decimal mark, or has no decimal mark.
-- Return '.' if text probably is using dot for decimal mark.
-- Otherwise return nothing (decimal mark not known).
if not text:find('[.,]') then return ',' end
text = text:gsub('^%-', ''):gsub('%+%d+/%d+$', ''):gsub('[Ee]%-?%d+$', '')
local decimal =
text:match('^0?([.,])%d+$') or
text:match('%d([.,])%d?%d?$') or
text:match('%d([.,])%d%d%d%d+$')
if decimal then return decimal end
if text:match('%.%d+%.') then return ',' end
if text:match('%,%d+,') then return '.' end
end
local add_warning, with_separator -- forward declarations
local function to_en_with_check(text, parms)
-- Version of to_en() for a wiki using numdot = ',' and numsep = '.' to check
-- text (an input number as a string) which might have been copied from enwiki.
-- For example, in '1.234' the '.' could be a decimal mark or a group separator.
-- From viwiki.
if to_en_table then
text = ustring.gsub(text, '%d', to_en_table)
end
if decimal_mark(text) == '.' then
local original = text
text = text:gsub(',', '') -- for example, interpret "1,234.5" as an enwiki value
if parms then
add_warning(parms, 0, 'cvt_enwiki_num', original, with_separator({}, text))
end
else
if numsep_remove then
text = text:gsub(numsep_remove, '')
end
if numsep_remove2 then
text = text:gsub(numsep_remove2, '')
end
if numdot ~= '.' then
text = text:gsub(numdot, '.')
end
end
return text
end
local function omit_separator(id)
-- Return true if there should be no separator before id (a unit symbol or name).
-- For zhwiki, there should be no separator if id uses local characters.
-- The following kludge should be a sufficient test.
if omitsep then
if id:sub(1, 2) == '-{' then -- for "-{...}-" content language variant
return true
end
if id:byte() > 127 then
local first = usub(id, 1, 1)
if first ~= 'Å' and first ~= '°' and first ~= 'µ' then
return true
end
end
end
return id:sub(1, 1) == '/' -- no separator before units like "/ha"
end
local spell_module -- name of module that can spell numbers
local speller -- function from that module to handle spelling (set if needed)
local wikidata_module, wikidata_data_module -- names of Wikidata modules
local wikidata_code, wikidata_data -- exported tables from those modules (set if needed)
local function set_config(args)
-- Set configuration options from template #invoke or defaults.
config = args
maxsigfig = config.maxsigfig or 14 -- maximum number of significant figures
local data_module, text_module
local sandbox = config.sandbox and ('/' .. config.sandbox) or ''
data_module = "Module:Convert/data" .. sandbox
text_module = "Module:Convert/text" .. sandbox
extra_module = "Module:Convert/extra" .. sandbox
wikidata_module = "Module:Convert/wikidata" .. sandbox
wikidata_data_module = "Module:Convert/wikidata/data" .. sandbox
spell_module = "Module:ConvertNumeric"
data_code = mw.loadData(data_module)
text_code = mw.loadData(text_module)
all_units = data_code.all_units
local translation = text_code.translation_table
if translation then
numdot = translation.numdot
numsep = translation.numsep
if numdot == ',' and numsep == '.' then
if text_code.all_messages.cvt_enwiki_num then
to_en = to_en_with_check
end
end
if translation.group then
group_method = translation.group
end
if translation.per_word then
per_word = translation.per_word
end
if translation.plural_suffix then
plural_suffix = translation.plural_suffix
end
varname = translation.varname
from_en_table = translation.from_en
local use_workaround = true
if use_workaround then
-- 2013-07-05 workaround bug by making a copy of the required table.
-- mw.ustring.gsub fails with a table (to_en_table) as the replacement,
-- if the table is accessed via mw.loadData.
local source = translation.to_en
if source then
to_en_table = {}
for k, v in pairs(source) do
to_en_table[k] = v
end
end
else
to_en_table = translation.to_en
end
if translation.lang == 'en default' then
en_default = true -- for hiwiki
end
omitsep = translation.omitsep -- for zhwiki
end
numdot = config.numdot or numdot or '.' -- decimal mark before fractional digits
numsep = config.numsep or numsep or ',' -- group separator for numbers
-- numsep should be ',' or '.' or '' or ' ' or a Unicode character.
-- numsep_remove must work in a regex to identify separators to be removed.
if numsep ~= '' then
numsep_remove = (numsep == '.') and '%.' or numsep
end
if numsep ~= ',' and numdot ~= ',' then
numsep_remove2 = ',' -- so numbers copied from enwiki will work
end
end
local function collection()
-- Return a table to hold items.
return {
n = 0,
add = function (self, item)
self.n = self.n + 1
self[self.n] = item
end,
}
end
local function divide(numerator, denominator)
-- Return integers quotient, remainder resulting from dividing the two
-- given numbers, which should be unsigned integers.
local quotient, remainder = floor(numerator / denominator), numerator % denominator
if not (0 <= remainder and remainder < denominator) then
-- Floating point limits may need this, as in {{convert|160.02|Ym|ydftin}}.
remainder = 0
end
return quotient, remainder
end
local function split(text, delimiter)
-- Return a numbered table with fields from splitting text.
-- The delimiter is used in a regex without escaping (for example, '.' would fail).
-- Each field has any leading/trailing whitespace removed.
local t = {}
text = text .. delimiter -- to get last item
for item in text:gmatch('%s*(.-)%s*' .. delimiter) do
table.insert(t, item)
end
return t
end
local function strip(text)
-- If text is a string, return its content with no leading/trailing
-- whitespace. Otherwise return nil (a nil argument gives a nil result).
if type(text) == 'string' then
return text:match("^%s*(.-)%s*$")
end
end
local function table_len(t)
-- Return length (<100) of a numbered table to replace #t which is
-- documented to not work if t is accessed via mw.loadData().
for i = 1, 100 do
if t[i] == nil then
return i - 1
end
end
end
local function wanted_category(catkey, catsort, want_warning)
-- Return message category if it is wanted in current namespace,
-- otherwise return ''.
local cat
local title = mw.title.getCurrentTitle()
if title then
local nsdefault = '0' -- default namespace: '0' = article; '0,10' = article and template
local namespace = title.namespace
for _, v in ipairs(split(config.nscat or nsdefault, ',')) do
if namespace == tonumber(v) then
cat = text_code.all_categories[want_warning and 'warning' or catkey]
if catsort and catsort ~= '' and cat:sub(-2) == ']]' then
cat = cat:sub(1, -3) .. '|' .. mw.text.nowiki(usub(catsort, 1, 20)) .. ']]'
end
break
end
end
end
return cat or ''
end
local function message(parms, mcode, is_warning)
-- Return wikitext for an error message, including category if specified
-- for the message type.
-- mcode = numbered table specifying the message:
-- mcode[1] = 'cvt_xxx' (string used as a key to get message info)
-- mcode[2] = 'parm1' (string to replace '$1' if any in message)
-- mcode[3] = 'parm2' (string to replace '$2' if any in message)
-- mcode[4] = 'parm3' (string to replace '$3' if any in message)
local msg
if type(mcode) == 'table' then
if mcode[1] == 'cvt_no_output' then
-- Some errors should cause convert to output an empty string,
-- for example, for an optional field in an infobox.
return ''
end
msg = text_code.all_messages[mcode[1]]
end
parms.have_problem = true
local function subparm(fmt, ...)
local rep = {}
for i, v in ipairs({...}) do
rep['$' .. i] = v
end
return (fmt:gsub('$%d+', rep))
end
if msg then
local parts = {}
local regex, replace = msg.regex, msg.replace
for i = 1, 3 do
local limit = 40
local s = mcode[i + 1]
if s then
if regex and replace then
s = s:gsub(regex, replace)
limit = nil -- allow long "should be" messages
end
-- Escape user input so it does not break the message.
-- To avoid tags (like {{convert|1<math>23</math>|m}}) breaking
-- the mouseover title, any strip marker starting with char(127) is
-- replaced with '...' (text not needing i18n).
local append
local pos = s:find(string.char(127), 1, true)
if pos then
append = '...'
s = s:sub(1, pos - 1)
end
if limit and ulen(s) > limit then
s = usub(s, 1, limit)
append = '...'
end
s = mw.text.nowiki(s) .. (append or '')
else
s = '?'
end
parts['$' .. i] = s
end
local function ispreview()
-- Return true if a prominent message should be shown.
if parms.test == 'preview' or parms.test == 'nopreview' then
-- For testing, can preview a real message or simulate a preview
-- when running automated tests.
return parms.test == 'preview'
end
local success, revid = pcall(function ()
return (parms.frame):preprocess('{{REVISIONID}}') end)
return success and (revid == '')
end
local want_warning = is_warning and
not config.warnings and -- show unobtrusive warnings if config.warnings not configured
not msg.nowarn -- but use msg settings, not standard warning, if specified
local title = string.gsub(msg[1] or 'Missing message', '$%d+', parts)
local text = want_warning and '*' or msg[2] or 'Missing message'
local cat = wanted_category(msg[3], mcode[2], want_warning)
local anchor = msg[4] or ''
local fmtkey = ispreview() and 'cvt_format_preview' or
(want_warning and 'cvt_format2' or msg.format or 'cvt_format')
local fmt = text_code.all_messages[fmtkey] or 'convert: bug'
return subparm(fmt, title:gsub('"', '"'), text, cat, anchor)
end
return 'Convert internal error: unknown message'
end
function add_warning(parms, level, key, text1, text2) -- for forward declaration above
-- If enabled, add a warning that will be displayed after the convert result.
-- A higher level is more verbose: more kinds of warnings are displayed.
-- To reduce output noise, only the first warning is displayed.
if level <= (tonumber(config.warnings) or 1) then
if parms.warnings == nil then
parms.warnings = message(parms, { key, text1, text2 }, true)
end
end
end
local function spell_number(parms, inout, number, numerator, denominator)
-- Return result of spelling (number, numerator, denominator), or
-- return nil if spelling is not available or not supported for given text.
-- Examples (each value must be a string or nil):
-- number numerator denominator output
-- ------ --------- ----------- -------------------
-- "1.23" nil nil one point two three
-- "1" "2" "3" one and two thirds
-- nil "2" "3" two thirds
if not speller then
local function get_speller(module)
return require(module).spell_number
end
local success
success, speller = pcall(get_speller, spell_module)
if not success or type(speller) ~= 'function' then
add_warning(parms, 1, 'cvt_no_spell', 'spell')
return nil
end
end
local case
if parms.spell_upper == inout then
case = true
parms.spell_upper = nil -- only uppercase first word in a multiple unit
end
local sp = not parms.opt_sp_us
local adj = parms.opt_adjectival
return speller(number, numerator, denominator, case, sp, adj)
end
------------------------------------------------------------------------
-- BEGIN: Code required only for built-in units.
-- LATER: If need much more code, move to another module to simplify this module.
local function speed_of_sound(altitude)
-- This is for the Mach built-in unit of speed.
-- Return speed of sound in metres per second at given altitude in feet.
-- If no altitude given, use default (zero altitude = sea level).
-- Table gives speed of sound in miles per hour at various altitudes:
-- altitude = -17,499 to 402,499 feet
-- mach_table[a + 4] = s where
-- a = (altitude / 5000) rounded to nearest integer (-3 to 80)
-- s = speed of sound (mph) at that altitude
-- LATER: Should calculate result from an interpolation between the next
-- lower and higher altitudes in table, rather than rounding to nearest.
-- From: http://www.aerospaceweb.org/question/atmosphere/q0112.shtml
local mach_table = { -- a =
799.5, 787.0, 774.2, 761.207051, -- -3 to 0
748.0, 734.6, 721.0, 707.0, 692.8, 678.3, 663.5, 660.1, 660.1, 660.1, -- 1 to 10
660.1, 660.1, 660.1, 662.0, 664.3, 666.5, 668.9, 671.1, 673.4, 675.6, -- 11 to 20
677.9, 683.7, 689.9, 696.0, 702.1, 708.1, 714.0, 719.9, 725.8, 731.6, -- 21 to 30
737.3, 737.7, 737.7, 736.2, 730.5, 724.6, 718.8, 712.9, 707.0, 701.0, -- 31 to 40
695.0, 688.9, 682.8, 676.6, 670.4, 664.1, 657.8, 652.9, 648.3, 643.7, -- 41 to 50
639.1, 634.4, 629.6, 624.8, 620.0, 615.2, 613.2, 613.2, 613.2, 613.5, -- 51 to 60
614.4, 615.3, 616.7, 619.8, 623.4, 629.7, 635.0, 641.1, 650.6, 660.0, -- 61 to 70
672.5, 674.3, 676.1, 677.9, 679.7, 681.5, 683.3, 685.1, 686.8, 688.6, -- 71 to 80
}
altitude = altitude or 0
local a = (altitude < 0) and -altitude or altitude
a = floor(a / 5000 + 0.5)
if altitude < 0 then
a = -a
end
if a < -3 then
a = -3
elseif a > 80 then
a = 80
end
return mach_table[a + 4] * 0.44704 -- mph converted to m/s
end
-- END: Code required only for built-in units.
------------------------------------------------------------------------
local function add_style(parms, class)
-- Add selected template style to parms if not already present.
parms.templatestyles = parms.templatestyles or {}
if not parms.templatestyles[class] then
parms.templatestyles[class] = parms.frame:extensionTag({
name = 'templatestyles', args = { src = text_code.titles[class] }
})
end
end
local function get_styles(parms)
-- Return string of required template styles, empty if none.
if parms.templatestyles then
local t = {}
for _, v in pairs(parms.templatestyles) do
table.insert(t, v)
end
return table.concat(t)
end
return ''
end
local function get_range(word)
-- Return a range (string or table) corresponding to word (like "to"),
-- or return nil if not a range word.
local ranges = text_code.ranges
return ranges.types[word] or ranges.types[ranges.aliases[word]]
end
local function check_mismatch(unit1, unit2)
-- If unit1 cannot be converted to unit2, return an error message table.
-- This allows conversion between units of the same type, and between
-- Nm (normally torque) and ftlb (energy), as in gun-related articles.
-- This works because Nm is the base unit (scale = 1) for both the
-- primary type (torque), and the alternate type (energy, where Nm = J).
-- A match occurs if the primary types are the same, or if unit1 matches
-- the alternate type of unit2, and vice versa. That provides a whitelist
-- of which conversions are permitted between normally incompatible types.
if unit1.utype == unit2.utype or
(unit1.utype == unit2.alttype and unit1.alttype == unit2.utype) then
return nil
end
return { 'cvt_mismatch', unit1.utype, unit2.utype }
end
local function override_from(out_table, in_table, fields)
-- Copy the specified fields from in_table to out_table, but do not
-- copy nil fields (keep any corresponding field in out_table).
for _, field in ipairs(fields) do
if in_table[field] then
out_table[field] = in_table[field]
end
end
end
local function shallow_copy(t)
-- Return a shallow copy of table t.
-- Do not need the features and overhead of the Scribunto mw.clone().
local result = {}
for k, v in pairs(t) do
result[k] = v
end
return result
end
local unit_mt = {
-- Metatable to get missing values for a unit that does not accept SI prefixes.
-- Warning: The boolean value 'false' is returned for any missing field
-- so __index is not called twice for the same field in a given unit.
__index = function (self, key)
local value
if key == 'name1' or key == 'sym_us' then
value = self.symbol
elseif key == 'name2' then
value = self.name1 .. plural_suffix
elseif key == 'name1_us' then
value = self.name1
if not rawget(self, 'name2_us') then
-- If name1_us is 'foot', do not make name2_us by appending plural_suffix.
self.name2_us = self.name2
end
elseif key == 'name2_us' then
local raw1_us = rawget(self, 'name1_us')
if raw1_us then
value = raw1_us .. plural_suffix
else
value = self.name2
end
elseif key == 'link' then
value = self.name1
else
value = false
end
rawset(self, key, value)
return value
end
}
local function prefixed_name(unit, name, index)
-- Return unit name with SI prefix inserted at correct position.
-- index = 1 (name1), 2 (name2), 3 (name1_us), 4 (name2_us).
-- The position is a byte (not character) index, so use Lua's sub().
local pos = rawget(unit, 'prefix_position')
if type(pos) == 'string' then
pos = tonumber(split(pos, ',')[index])
end
if pos then
return name:sub(1, pos - 1) .. unit.si_name .. name:sub(pos)
end
return unit.si_name .. name
end
local unit_prefixed_mt = {
-- Metatable to get missing values for a unit that accepts SI prefixes.
-- Before use, fields si_name, si_prefix must be defined.
-- The unit must define _symbol, _name1 and
-- may define _sym_us, _name1_us, _name2_us
-- (_sym_us, _name2_us may be defined for a language using sp=us
-- to refer to a variant unrelated to U.S. units).
__index = function (self, key)
local value
if key == 'symbol' then
value = self.si_prefix .. self._symbol
if value == 'l' then value = 'L' end
elseif key == 'sym_us' then
value = rawget(self, '_sym_us')
if value then
value = self.si_prefix .. value
else
value = self.symbol
end
elseif key == 'name1' then
value = prefixed_name(self, self._name1, 1)
elseif key == 'name2' then
value = rawget(self, '_name2')
if value then
value = prefixed_name(self, value, 2)
else
value = self.name1 .. plural_suffix
end
elseif key == 'name1_us' then
value = rawget(self, '_name1_us')
if value then
value = prefixed_name(self, value, 3)
else
value = self.name1
end
elseif key == 'name2_us' then
value = rawget(self, '_name2_us')
if value then
value = prefixed_name(self, value, 4)
elseif rawget(self, '_name1_us') then
value = self.name1_us .. plural_suffix
else
value = self.name2
end
elseif key == 'link' then
value = self.name1
else
value = false
end
rawset(self, key, value)
return value
end
}
local unit_per_mt = {
-- Metatable to get values for a per unit of form "x/y".
-- This is never called to determine a unit name or link because per units
-- are handled as a special case.
-- Similarly, the default output is handled elsewhere, and for a symbol
-- this is only called from get_default() for default_exceptions.
__index = function (self, key)
local value
if key == 'symbol' then
local per = self.per
local unit1, unit2 = per[1], per[2]
if unit1 then
value = unit1[key] .. '/' .. unit2[key]
else
value = '/' .. unit2[key]
end
elseif key == 'sym_us' then
value = self.symbol
elseif key == 'scale' then
local per = self.per
local unit1, unit2 = per[1], per[2]
value = (unit1 and unit1.scale or 1) * self.scalemultiplier / unit2.scale
else
value = false
end
rawset(self, key, value)
return value
end
}
local function make_per(unitcode, unit_table, ulookup)
-- Return true, t where t is a per unit with unit codes expanded to unit tables,
-- or return false, t where t is an error message table.
local result = {
unitcode = unitcode,
utype = unit_table.utype,
per = {}
}
override_from(result, unit_table, { 'invert', 'iscomplex', 'default', 'link', 'symbol', 'symlink' })
result.symbol_raw = (result.symbol or false) -- to distinguish between a defined exception and a metatable calculation
local prefix
for i, v in ipairs(unit_table.per) do
if i == 1 and v == '' then
-- First unit symbol can be empty; that gives a nil first unit table.
elseif i == 1 and text_code.currency[v] then
prefix = currency_text or v
else
local success, t = ulookup(v)
if not success then return false, t end
result.per[i] = t
end
end
local multiplier = unit_table.multiplier
if not result.utype then
-- Creating an automatic per unit.
local unit1 = result.per[1]
local utype = (unit1 and unit1.utype or prefix or '') .. '/' .. result.per[2].utype
local t = data_code.per_unit_fixups[utype]
if t then
if type(t) == 'table' then
utype = t.utype or utype
result.link = result.link or t.link
multiplier = multiplier or t.multiplier
else
utype = t
end
end
result.utype = utype
end
result.scalemultiplier = multiplier or 1
result.vprefix = prefix or false -- set to non-nil to avoid calling __index
return true, setmetatable(result, unit_per_mt)
end
local function lookup(parms, unitcode, what, utable, fails, depth)
-- Return true, t where t is a copy of the unit's converter table,
-- or return false, t where t is an error message table.
-- Parameter 'what' determines whether combination units are accepted:
-- 'no_combination' : single unit only
-- 'any_combination' : single unit or combination or output multiple
-- 'only_multiple' : single unit or output multiple only
-- Parameter unitcode is a symbol (like 'g'), with an optional SI prefix (like 'kg').
-- If, for example, 'kg' is in this table, that entry is used;
-- otherwise the prefix ('k') is applied to the base unit ('g').
-- If unitcode is a known combination code (and if allowed by what),
-- a table of output multiple unit tables is included in the result.
-- For compatibility with the old template, an underscore in a unitcode is
-- replaced with a space so usage like {{convert|350|board_feet}} works.
-- Wikignomes may also put two spaces or " " in combinations, so
-- replace underscore, " ", and multiple spaces with a single space.
utable = utable or parms.unittable or all_units
fails = fails or {}
depth = depth and depth + 1 or 1
if depth > 9 then
-- There are ways to mistakenly define units which result in infinite
-- recursion when lookup() is called. That gives a long delay and very
-- confusing error messages, so the depth parameter is used as a guard.
return false, { 'cvt_lookup', unitcode }
end
if unitcode == nil or unitcode == '' then
return false, { 'cvt_no_unit' }
end
unitcode = unitcode:gsub('_', ' '):gsub(' ', ' '):gsub(' +', ' ')
local function call_make_per(t)
return make_per(unitcode, t,
function (ucode) return lookup(parms, ucode, 'no_combination', utable, fails, depth) end
)
end
local t = utable[unitcode]
if t then
if t.shouldbe then
return false, { 'cvt_should_be', t.shouldbe }
end
if t.sp_us then
parms.opt_sp_us = true
end
local target = t.target -- nil, or unitcode is an alias for this target
if target then
local success, result = lookup(parms, target, what, utable, fails, depth)
if not success then return false, result end
override_from(result, t, { 'customary', 'default', 'link', 'symbol', 'symlink' })
local multiplier = t.multiplier
if multiplier then
result.multiplier = tostring(multiplier)
result.scale = result.scale * multiplier
end
return true, result
end
if t.per then
return call_make_per(t)
end
local combo = t.combination -- nil or a table of unitcodes
if combo then
local multiple = t.multiple
if what == 'no_combination' or (what == 'only_multiple' and not multiple) then
return false, { 'cvt_bad_unit', unitcode }
end
-- Recursively create a combination table containing the
-- converter table of each unitcode.
local result = { utype = t.utype, multiple = multiple, combination = {} }
local cvt = result.combination
for i, v in ipairs(combo) do
local success, t = lookup(parms, v, multiple and 'no_combination' or 'only_multiple', utable, fails, depth)
if not success then return false, t end
cvt[i] = t
end
return true, result
end
local result = shallow_copy(t)
result.unitcode = unitcode
if result.prefixes then
result.si_name = ''
result.si_prefix = ''
return true, setmetatable(result, unit_prefixed_mt)
end
return true, setmetatable(result, unit_mt)
end
local SIprefixes = text_code.SIprefixes
for plen = SIprefixes[1] or 2, 1, -1 do
-- Look for an SI prefix; should never occur with an alias.
-- Check for longer prefix first ('dam' is decametre).
-- SIprefixes[1] = prefix maximum #characters (as seen by mw.ustring.sub).
local prefix = usub(unitcode, 1, plen)
local si = SIprefixes[prefix]
if si then
local t = utable[usub(unitcode, plen+1)]
if t and t.prefixes then
local result = shallow_copy(t)
result.unitcode = unitcode
result.si_name = parms.opt_sp_us and si.name_us or si.name
result.si_prefix = si.prefix or prefix
result.scale = t.scale * 10 ^ (si.exponent * t.prefixes)
return true, setmetatable(result, unit_prefixed_mt)
end
end
end
-- Accept user-defined combinations like "acre+m2+ha" or "acre m2 ha" for output.
-- If '+' is used, each unit code can include a space, and any error is fatal.
-- If ' ' is used and if each space-separated word is a unit code, it is a combo,
-- but errors are not fatal so the unit code can be looked up as an extra unit.
local err_is_fatal
local combo = collection()
if unitcode:find('+', 1, true) then
err_is_fatal = true
for item in (unitcode .. '+'):gmatch('%s*(.-)%s*%+') do
if item ~= '' then
combo:add(item)
end
end
elseif unitcode:find('%s') then
for item in unitcode:gmatch('%S+') do
combo:add(item)
end
end
if combo.n > 1 then
local function lookup_combo()
if what == 'no_combination' or what == 'only_multiple' then
return false, { 'cvt_bad_unit', unitcode }
end
local result = { combination = {} }
local cvt = result.combination
for i, v in ipairs(combo) do
local success, t = lookup(parms, v, 'only_multiple', utable, fails, depth)
if not success then return false, t end
if i == 1 then
result.utype = t.utype
else
local mismatch = check_mismatch(result, t)
if mismatch then
return false, mismatch
end
end
cvt[i] = t
end
return true, result
end
local success, result = lookup_combo()
if success or err_is_fatal then
return success, result
end
end
-- Accept any unit with an engineering notation prefix like "e6cuft"
-- (million cubic feet), but not chained prefixes like "e3e6cuft",
-- and not if the unit is a combination or multiple,
-- and not if the unit has an offset or is a built-in.
-- Only en digits are accepted.
local exponent, baseunit = unitcode:match('^e(%d+)(.*)')
if exponent then
local engscale = text_code.eng_scales[exponent]
if engscale then
local success, result = lookup(parms, baseunit, 'no_combination', utable, fails, depth)
if success and not (result.offset or result.builtin or result.engscale) then
result.unitcode = unitcode -- 'e6cuft' not 'cuft'
result.defkey = unitcode -- key to lookup default exception
result.engscale = engscale
result.scale = result.scale * 10 ^ tonumber(exponent)
return true, result
end
end
end
-- Look for x/y; split on right-most slash to get scale correct (x/y/z is x/y per z).
local top, bottom = unitcode:match('^(.-)/([^/]+)$')
if top and not unitcode:find('e%d') then
-- If valid, create an automatic per unit for an "x/y" unit code.
-- The unitcode must not include extraneous spaces.
-- Engineering notation (apart from at start and which has been stripped before here),
-- is not supported so do not make a per unit if find text like 'e3' in unitcode.
local success, result = call_make_per({ per = {top, bottom} })
if success then
return true, result
end
end
if not parms.opt_ignore_error and not get_range(unitcode) then
-- Want the "what links here" list for the extra_module to show only cases
-- where an extra unit is used, so do not require it if invoked from {{val}}
-- or if looking up a range word which cannot be a unit.
if not extra_units then
local success, extra = pcall(function () return require(extra_module).extra_units end)
if success and type(extra) == 'table' then
extra_units = extra
end
end
if extra_units then
-- A unit in one data table might refer to a unit in the other table, so
-- switch between them, relying on fails or depth to terminate loops.
if not fails[unitcode] then
fails[unitcode] = true
local other = (utable == all_units) and extra_units or all_units
local success, result = lookup(parms, unitcode, what, other, fails, depth)
if success then
return true, result
end
end
end
end
if to_en_table then
-- At fawiki it is common to translate all digits so a unit like "km2" becomes "km۲".
local en_code = ustring.gsub(unitcode, '%d', to_en_table)
if en_code ~= unitcode then
return lookup(parms, en_code, what, utable, fails, depth)
end
end
return false, { 'cvt_unknown', unitcode }
end
local function valid_number(num)
-- Return true if num is a valid number.
-- In Scribunto (different from some standard Lua), when expressed as a string,
-- overflow or other problems are indicated with text like "inf" or "nan"
-- which are regarded as invalid here (each contains "n").
if type(num) == 'number' and tostring(num):find('n', 1, true) == nil then
return true
end
end
local function hyphenated(name, parts)
-- Return a hyphenated form of given name (for adjectival usage).
-- The name may be linked and the target of the link must not be changed.
-- Hypothetical examples:
-- [[long ton|ton]] → [[long ton|ton]] (no change)
-- [[tonne|long ton]] → [[tonne|long-ton]]
-- [[metric ton|long ton]] → [[metric ton|long-ton]]
-- [[long ton]] → [[long ton|long-ton]]
-- Input can also have multiple links in a single name like:
-- [[United States customary units|U.S.]] [[US gallon|gallon]]
-- [[mile]]s per [[United States customary units|U.S.]] [[quart]]
-- [[long ton]]s per [[short ton]]
-- Assume that links cannot be nested (never like "[[abc[[def]]ghi]]").
-- This uses a simple and efficient procedure that works for most cases.
-- Some units (if used) would require more, and can later think about
-- adding a method to handle exceptions.
-- The procedure is to replace each space with a hyphen, but
-- not a space after ')' [for "(pre-1954 US) nautical mile"], and
-- not spaces immediately before '(' or in '(...)' [for cases like
-- "British thermal unit (ISO)" and "Calorie (International Steam Table)"].
if name:find(' ', 1, true) then
if parts then
local pos
if name:sub(1, 1) == '(' then
pos = name:find(')', 1, true)
if pos then
return name:sub(1, pos+1) .. name:sub(pos+2):gsub(' ', '-')
end
elseif name:sub(-1) == ')' then
pos = name:find('(', 1, true)
if pos then
return name:sub(1, pos-2):gsub(' ', '-') .. name:sub(pos-1)
end
end
return name:gsub(' ', '-')
end
parts = collection()
for before, item, after in name:gmatch('([^[]*)(%[%[[^[]*%]%])([^[]*)') do
if item:find(' ', 1, true) then
local prefix
local plen = item:find('|', 1, true)
if plen then
prefix = item:sub(1, plen)
item = item:sub(plen + 1, -3)
else
prefix = item:sub(1, -3) .. '|'
item = item:sub(3, -3)
end
item = prefix .. hyphenated(item, parts) .. ']]'
end
parts:add(before:gsub(' ', '-') .. item .. after:gsub(' ', '-'))
end
if parts.n == 0 then
-- No link like "[[...]]" was found in the original name.
parts:add(hyphenated(name, parts))
end
return table.concat(parts)
end
return name
end
local function hyphenated_maybe(parms, want_name, sep, id, inout)
-- Return s, f where
-- s = id, possibly modified
-- f = true if hyphenated
-- Possible modifications: hyphenate; prepend '-'; append mid text.
if id == nil or id == '' then
return ''
end
local mid = (inout == (parms.opt_flip and 'out' or 'in')) and parms.mid or ''
if want_name then
if parms.opt_adjectival then
return '-' .. hyphenated(id) .. mid, true
end
if parms.opt_add_s and id:sub(-1) ~= 's' then
id = id .. 's' -- for nowiki
end
end
return sep .. id .. mid
end
local function use_minus(text)
-- Return text with Unicode minus instead of '-', if present.
if text:sub(1, 1) == '-' then
return MINUS .. text:sub(2)
end
return text
end
local function digit_groups(parms, text, method)
-- Return a numbered table of groups of digits (left-to-right, in local language).
-- Parameter method is a number or nil:
-- 3 for 3-digit grouping (default), or
-- 2 for 3-then-2 grouping (only for digits before decimal mark).
local len_right
local len_left = text:find('.', 1, true)
if len_left then
len_right = #text - len_left
len_left = len_left - 1
else
len_left = #text
end
local twos = method == 2 and len_left > 5
local groups = collection()
local run = len_left
local n
if run < 4 or (run == 4 and parms.opt_comma5) then
if parms.opt_gaps then
n = run
else
n = #text
end
elseif twos then
n = run % 2 == 0 and 1 or 2
else
n = run % 3 == 0 and 3 or run % 3
end
while run > 0 do
groups:add(n)
run = run - n
n = (twos and run > 3) and 2 or 3
end
if len_right then
if groups.n == 0 then
groups:add(0)
end
if parms.opt_gaps and len_right > 3 then
local want4 = not parms.opt_gaps3 -- true gives no gap before trailing single digit
local isfirst = true
run = len_right
while run > 0 do
n = (want4 and run == 4) and 4 or (run > 3 and 3 or run)
if isfirst then
isfirst = false
groups[groups.n] = groups[groups.n] + 1 + n
else
groups:add(n)
end
run = run - n
end
else
groups[groups.n] = groups[groups.n] + 1 + len_right
end
end
local pos = 1
for i, length in ipairs(groups) do
groups[i] = from_en(text:sub(pos, pos + length - 1))
pos = pos + length
end
return groups
end
function with_separator(parms, text) -- for forward declaration above
-- Input text is a number in en digits with optional '.' decimal mark.
-- Return an equivalent, formatted for display:
-- with a custom decimal mark instead of '.', if wanted
-- with thousand separators inserted, if wanted
-- digits in local language
-- The given text is like '123' or '123.' or '12345.6789'.
-- The text has no sign (caller inserts that later, if necessary).
-- When using gaps, they are inserted before and after the decimal mark.
-- Separators are inserted only before the decimal mark.
-- A trailing dot (as in '123.') is removed because their use appears to
-- be accidental, and such a number should be shown as '123' or '123.0'.
-- It is useful for convert to suppress the dot so, for example, '4000.'
-- is a simple way of indicating that all the digits are significant.
if text:sub(-1) == '.' then
text = text:sub(1, -2)
end
if #text < 4 or parms.opt_nocomma or numsep == '' then
return from_en(text)
end
local groups = digit_groups(parms, text, group_method)
if parms.opt_gaps then
if groups.n <= 1 then
return groups[1] or ''
end
local nowrap = '<span style="white-space: nowrap">'
local gap = '<span style="margin-left: 0.25em">'
local close = '</span>'
return nowrap .. groups[1] .. gap .. table.concat(groups, close .. gap, 2, groups.n) .. close .. close
end
return table.concat(groups, numsep)
end
-- An input value like 1.23e12 is displayed using scientific notation (1.23×10¹²).
-- That also makes the output use scientific notation, except for small values.
-- In addition, very small or very large output values use scientific notation.
-- Use format(fmtpower, significand, '10', exponent) where each argument is a string.
local fmtpower = '%s<span style="margin:0 .15em 0 .25em">×</span>%s<sup>%s</sup>'
local function with_exponent(parms, show, exponent)
-- Return wikitext to display the implied value in scientific notation.
-- Input uses en digits; output uses digits in local language.
return format(fmtpower, with_separator(parms, show), from_en('10'), use_minus(from_en(tostring(exponent))))
end
local function make_sigfig(value, sigfig)
-- Return show, exponent that are equivalent to the result of
-- converting the number 'value' (where value >= 0) to a string,
-- rounded to 'sigfig' significant figures.
-- The returned items are:
-- show: a string of digits; no sign and no dot;
-- there is an implied dot before show.
-- exponent: a number (an integer) to shift the implied dot.
-- Resulting value = tonumber('.' .. show) * 10^exponent.
-- Examples:
-- make_sigfig(23.456, 3) returns '235', 2 (.235 * 10^2).
-- make_sigfig(0.0023456, 3) returns '235', -2 (.235 * 10^-2).
-- make_sigfig(0, 3) returns '000', 1 (.000 * 10^1).
if sigfig <= 0 then
sigfig = 1
elseif sigfig > maxsigfig then
sigfig = maxsigfig
end
if value == 0 then
return string.rep('0', sigfig), 1
end
local exp, fracpart = math.modf(log10(value))
if fracpart >= 0 then
fracpart = fracpart - 1
exp = exp + 1
end
local digits = format('%.0f', 10^(fracpart + sigfig))
if #digits > sigfig then
-- Overflow (for sigfig=3: like 0.9999 rounding to "1000"; need "100").
digits = digits:sub(1, sigfig)
exp = exp + 1
end
assert(#digits == sigfig, 'Bug: rounded number has wrong length')
return digits, exp
end
-- Fraction output format.
local fracfmt = {
{ -- Like {{frac}} (fraction slash).
'<span class="frac" role="math">{SIGN}<span class="num">{NUM}</span>⁄<span class="den">{DEN}</span></span>', -- 1/2
'<span class="frac" role="math">{SIGN}{WHOLE}<span class="sr-only">+</span><span class="num">{NUM}</span>⁄<span class="den">{DEN}</span></span>', -- 1+2/3
style = 'frac',
},
{ -- Like {{sfrac}} (stacked fraction, that is, horizontal bar).
'<span class="sfrac tion" role="math">{SIGN}<span class="num">{NUM}</span><span class="sr-only">/</span><span class="den">{DEN}</span></span>', -- 1//2
'<span class="sfrac" role="math">{SIGN}{WHOLE}<span class="sr-only">+</span><span class="tion"><span class="num">{NUM}</span><span class="sr-only">/</span><span class="den">{DEN}</span></span></span>', -- 1+2//3
style = 'sfrac',
},
}
local function format_fraction(parms, inout, negative, wholestr, numstr, denstr, do_spell, style)
-- Return wikitext for a fraction, possibly spelled.
-- Inputs use en digits and have no sign; output uses digits in local language.
local wikitext
if not style then
style = parms.opt_fraction_horizontal and 2 or 1
end
if wholestr == '' then
wholestr = nil
end
local substitute = {
SIGN = negative and MINUS or '',
WHOLE = wholestr and with_separator(parms, wholestr),
NUM = from_en(numstr),
DEN = from_en(denstr),
}
wikitext = fracfmt[style][wholestr and 2 or 1]:gsub('{(%u+)}', substitute)
if do_spell then
if negative then
if wholestr then
wholestr = '-' .. wholestr
else
numstr = '-' .. numstr
end
end
local s = spell_number(parms, inout, wholestr, numstr, denstr)
if s then
return s
end
end
add_style(parms, fracfmt[style].style)
return wikitext
end
local function format_number(parms, show, exponent, isnegative)
-- Parameter show is a string or a table containing strings.
-- Each string is a formatted number in en digits and optional '.' decimal mark.
-- A table represents a fraction: integer, numerator, denominator;
-- if a table is given, exponent must be nil.
-- Return t where t is a table with fields:
-- show = wikitext formatted to display implied value
-- (digits in local language)
-- is_scientific = true if show uses scientific notation
-- clean = unformatted show (possibly adjusted and with inserted '.')
-- (en digits)
-- sign = '' or MINUS
-- exponent = exponent (possibly adjusted)
-- The clean and exponent fields can be used to calculate the
-- rounded absolute value, if needed.
--
-- The value implied by the arguments is found from:
-- exponent is nil; and
-- show is a string of digits (no sign), with an optional dot;
-- show = '123.4' is value 123.4, '1234' is value 1234.0;
-- or:
-- exponent is an integer indicating where dot should be;
-- show is a string of digits (no sign and no dot);
-- there is an implied dot before show;
-- show does not start with '0';
-- show = '1234', exponent = 3 is value 0.1234*10^3 = 123.4.
--
-- The formatted result:
-- * Is for an output value and is spelled if wanted and possible.
-- * Includes a Unicode minus if isnegative and not spelled.
-- * Uses a custom decimal mark, if wanted.
-- * Has digits grouped where necessary, if wanted.
-- * Uses scientific notation if requested, or for very small or large values
-- (which forces result to not be spelled).
-- * Has no more than maxsigfig significant digits
-- (same as old template and {{#expr}}).
local xhi, xlo -- these control when scientific notation (exponent) is used
if parms.opt_scientific then
xhi, xlo = 4, 2 -- default for output if input uses e-notation
elseif parms.opt_scientific_always then
xhi, xlo = 0, 0 -- always use scientific notation (experimental)
else
xhi, xlo = 10, 4 -- default
end
local sign = isnegative and MINUS or ''
local maxlen = maxsigfig
local tfrac
if type(show) == 'table' then
tfrac = show
show = tfrac.wholestr
assert(exponent == nil, 'Bug: exponent given with fraction')
end
if not tfrac and not exponent then
local integer, dot, decimals = show:match('^(%d*)(%.?)(.*)')
if integer == '0' or integer == '' then
local zeros, figs = decimals:match('^(0*)([^0]?.*)')
if #figs == 0 then
if #zeros > maxlen then
show = '0.' .. zeros:sub(1, maxlen)
end
elseif #zeros >= xlo then
show = figs
exponent = -#zeros
elseif #figs > maxlen then
show = '0.' .. zeros .. figs:sub(1, maxlen)
end
elseif #integer >= xhi then
show = integer .. decimals
exponent = #integer
else
maxlen = maxlen + #dot
if #show > maxlen then
show = show:sub(1, maxlen)
end
end
end
if exponent then
local function zeros(n)
return string.rep('0', n)
end
if #show > maxlen then
show = show:sub(1, maxlen)
end
if exponent > xhi or exponent <= -xlo or (exponent == xhi and show ~= '1' .. zeros(xhi - 1)) then
-- When xhi, xlo = 10, 4 (the default), scientific notation is used if the
-- rounded value satisfies: value >= 1e9 or value < 1e-4 (1e9 = 0.1e10),
-- except if show is '1000000000' (1e9), for example:
-- {{convert|1000000000|m|m|sigfig=10}} → 1,000,000,000 metres (1,000,000,000 m)
local significand
if #show > 1 then
significand = show:sub(1, 1) .. '.' .. show:sub(2)
else
significand = show
end
return {
clean = '.' .. show,
exponent = exponent,
sign = sign,
show = sign .. with_exponent(parms, significand, exponent-1),
is_scientific = true,
}
end
if exponent >= #show then
show = show .. zeros(exponent - #show) -- result has no dot
elseif exponent <= 0 then
show = '0.' .. zeros(-exponent) .. show
else
show = show:sub(1, exponent) .. '.' .. show:sub(exponent+1)
end
end
local formatted_show
if tfrac then
show = tostring(tfrac.value) -- to set clean in returned table
formatted_show = format_fraction(parms, 'out', isnegative, tfrac.wholestr, tfrac.numstr, tfrac.denstr, parms.opt_spell_out)
else
if isnegative and show:match('^0.?0*$') then
sign = '' -- don't show minus if result is negative but rounds to zero
end
formatted_show = sign .. with_separator(parms, show)
if parms.opt_spell_out then
formatted_show = spell_number(parms, 'out', sign .. show) or formatted_show
end
end
return {
clean = show,
sign = sign,
show = formatted_show,
is_scientific = false, -- to avoid calling __index
}
end
local function extract_fraction(parms, text, negative)
-- If text represents a fraction, return
-- value, altvalue, show, denominator
-- where
-- value is a number (value of the fraction in argument text)
-- altvalue is an alternate interpretation of any fraction for the hands
-- unit where "12.1+3/4" means 12 hands 1.75 inches
-- show is a string (formatted text for display of an input value,
-- and is spelled if wanted and possible)
-- denominator is value of the denominator in the fraction
-- Otherwise, return nil.
-- Input uses en digits and '.' decimal mark (input has been translated).
-- Output uses digits in local language and local decimal mark, if any.
------------------------------------------------------------------------
-- Originally this function accepted x+y/z where x, y, z were any valid
-- numbers, possibly with a sign. For example '1.23e+2+1.2/2.4' = 123.5,
-- and '2-3/8' = 1.625. However, such usages were found to be errors or
-- misunderstandings, so since August 2014 the following restrictions apply:
-- x (if present) is an integer or has a single digit after decimal mark
-- y and z are unsigned integers
-- e-notation is not accepted
-- The overall number can start with '+' or '-' (so '12+3/4' and '+12+3/4'
-- and '-12-3/4' are valid).
-- Any leading negative sign is removed by the caller, so only inputs
-- like the following are accepted here (may have whitespace):
-- negative = false false true (there was a leading '-')
-- text = '2/3' '+2/3' '2/3'
-- text = '1+2/3' '+1+2/3' '1-2/3'
-- text = '12.3+1/2' '+12.3+1/2' '12.3-1/2'
-- Values like '12.3+1/2' are accepted, but are intended only for use
-- with the hands unit (not worth adding code to enforce that).
------------------------------------------------------------------------
local leading_plus, prefix, numstr, slashes, denstr =
text:match('^%s*(%+?)%s*(.-)%s*(%d+)%s*(/+)%s*(%d+)%s*$')
if not leading_plus then
-- Accept a single U+2044 fraction slash because that may be pasted.
leading_plus, prefix, numstr, denstr =
text:match('^%s*(%+?)%s*(.-)%s*(%d+)%s*⁄%s*(%d+)%s*$')
slashes = '/'
end
local numerator = tonumber(numstr)
local denominator = tonumber(denstr)
if numerator == nil or denominator == nil or (negative and leading_plus ~= '') then
return nil
end
local whole, wholestr
if prefix == '' then
wholestr = ''
whole = 0
else
-- Any prefix must be like '12+' or '12-' (whole number and fraction sign);
-- '12.3+' and '12.3-' are also accepted (single digit after decimal point)
-- because '12.3+1/2 hands' is valid (12 hands 3½ inches).
local num1, num2, frac_sign = prefix:match('^(%d+)(%.?%d?)%s*([+%-])$')
if num1 == nil then return nil end
if num2 == '' then -- num2 must be '' or like '.1' but not '.' or '.12'
wholestr = num1
else
if #num2 ~= 2 then return nil end
wholestr = num1 .. num2
end
if frac_sign ~= (negative and '-' or '+') then return nil end
whole = tonumber(wholestr)
if whole == nil then return nil end
end
local value = whole + numerator / denominator
if not valid_number(value) then return nil end
local altvalue = whole + numerator / (denominator * 10)
local style = #slashes -- kludge: 1 or 2 slashes can be used to select style
if style > 2 then style = 2 end
local wikitext = format_fraction(parms, 'in', negative, leading_plus .. wholestr, numstr, denstr, parms.opt_spell_in, style)
return value, altvalue, wikitext, denominator
end
local function extract_number(parms, text, another, no_fraction)
-- Return true, info if can extract a number from text,
-- where info is a table with the result,
-- or return false, t where t is an error message table.
-- Input can use en digits or digits in local language and can
-- have references at the end. Accepting references is intended
-- for use in infoboxes with a field for a value passed to convert.
-- Parameter another = true if the expected value is not the first.
-- Before processing, the input text is cleaned:
-- * Any thousand separators (valid or not) are removed.
-- * Any sign is replaced with '-' (if negative) or '' (otherwise).
-- That replaces Unicode minus with '-'.
-- If successful, the returned info table contains named fields:
-- value = a valid number
-- altvalue = a valid number, usually same as value but different
-- if fraction used (for hands unit)
-- singular = true if value is 1 or -1 (to use singular form of units)
-- clean = cleaned text with any separators and sign removed
-- (en digits and '.' decimal mark)
-- show = text formatted for output, possibly with ref strip markers
-- (digits in local language and custom decimal mark)
-- The resulting show:
-- * Is for an input value and is spelled if wanted and possible.
-- * Has a rounded value, if wanted.
-- * Has digits grouped where necessary, if wanted.
-- * If negative, a Unicode minus is used; otherwise the sign is
-- '+' (if the input text used '+'), or is '' (if no sign in input).
text = strip(text or '')
local reference
local pos = text:find('\127', 1, true)
if pos then
local before = text:sub(1, pos - 1)
local remainder = text:sub(pos)
local refs = {}
while #remainder > 0 do
local ref, spaces
ref, spaces, remainder = remainder:match('^(\127[^\127]*UNIQ[^\127]*%-ref[^\127]*\127)(%s*)(.*)')
if ref then
table.insert(refs, ref)
else
refs = {}
break
end
end
if #refs > 0 then
text = strip(before)
reference = table.concat(refs)
end
end
local clean = to_en(text, parms)
if clean == '' then
return false, { another and 'cvt_no_num2' or 'cvt_no_num' }
end
local isnegative, propersign = false, '' -- most common case
local singular, show, denominator
local value = tonumber(clean)
local altvalue
if value then
local sign = clean:sub(1, 1)
if sign == '+' or sign == '-' then
propersign = (sign == '+') and '+' or MINUS
clean = clean:sub(2)
end
if value < 0 then
isnegative = true
value = -value
end
else
local valstr
for _, prefix in ipairs({ '-', MINUS, '−' }) do
-- Including '-' sets isnegative in case input is a fraction like '-2-3/4'.
local plen = #prefix
if clean:sub(1, plen) == prefix then
valstr = clean:sub(plen + 1)
if valstr:match('^%s') then -- "- 1" is invalid but "-1 - 1/2" is ok
return false, { 'cvt_bad_num', text }
end
break
end
end
if valstr then
isnegative = true
propersign = MINUS
clean = valstr
value = tonumber(clean)
end
if value == nil then
if not no_fraction then
value, altvalue, show, denominator = extract_fraction(parms, clean, isnegative)
end
if value == nil then
return false, { 'cvt_bad_num', text }
end
if value <= 1 then
singular = true -- for example, "½ mile" or "one half mile" (singular unit)
end
end
end
if not valid_number(value) then -- for example, "1e310" may overflow
return false, { 'cvt_invalid_num' }
end
if show == nil then
-- clean is a non-empty string with no spaces, and does not represent a fraction,
-- and value = tonumber(clean) is a number >= 0.
-- If the input uses e-notation, show will be displayed using a power of ten, but
-- we use the number as given so it might not be normalized scientific notation.
-- The input value is spelled if specified so any e-notation is ignored;
-- that allows input like 2e6 to be spelled as "two million" which works
-- because the spell module converts '2e6' to '2000000' before spelling.
local function rounded(value, default, exponent)
local precision = parms.opt_ri
if precision then
local fmt = '%.' .. format('%d', precision) .. 'f'
local result = fmt:format(tonumber(value) + 2e-14) -- fudge for some common cases of bad rounding
if not exponent then
singular = (tonumber(result) == 1)
end
return result
end
return default
end
singular = (value == 1)
local scientific
local significand, exponent = clean:match('^([%d.]+)[Ee]([+%-]?%d+)')
if significand then
show = with_exponent(parms, rounded(significand, significand, exponent), exponent)
scientific = true
else
show = with_separator(parms, rounded(value, clean))
end
show = propersign .. show
if parms.opt_spell_in then
show = spell_number(parms, 'in', propersign .. rounded(value, clean)) or show
scientific = false
end
if scientific then
parms.opt_scientific = true
end
end
if isnegative and (value ~= 0) then
value = -value
altvalue = -(altvalue or value)
end
return true, {
value = value,
altvalue = altvalue or value,
singular = singular,
clean = clean,
show = show .. (reference or ''),
denominator = denominator,
}
end
local function get_number(text)
-- Return v, f where:
-- v = nil (text is not a number)
-- or
-- v = value of text (text is a number)
-- f = true if value is an integer
-- Input can use en digits or digits in local language or separators,
-- but no Unicode minus, and no fraction.
if text then
local number = tonumber(to_en(text))
if number then
local _, fracpart = math.modf(number)
return number, (fracpart == 0)
end
end
end
local function gcd(a, b)
-- Return the greatest common denominator for the given values,
-- which are known to be positive integers.
if a > b then
a, b = b, a
end
if a <= 0 then
return b
end
local r = b % a
if r <= 0 then
return a
end
if r == 1 then
return 1
end
return gcd(r, a)
end
local function fraction_table(value, denominator)
-- Return value as a string or a table:
-- * If result is a string, there is no fraction, and the result
-- is value formatted as a string of en digits.
-- * If result is a table, it represents a fraction with named fields:
-- wholestr, numstr, denstr (strings of en digits for integer, numerator, denominator).
-- The result is rounded to the nearest multiple of (1/denominator).
-- If the multiple is zero, no fraction is included.
-- No fraction is included if value is very large as the fraction would
-- be unhelpful, particularly if scientific notation is required.
-- Input value is a non-negative number.
-- Input denominator is a positive integer for the desired fraction.
if value <= 0 then
return '0'
end
if denominator <= 0 or value > 1e8 then
return format('%.2f', value)
end
local integer, decimals = math.modf(value)
local numerator = floor((decimals * denominator) +
0.5 + 2e-14) -- add fudge for some common cases of bad rounding
if numerator >= denominator then
integer = integer + 1
numerator = 0
end
local wholestr = tostring(integer)
if numerator > 0 then
local div = gcd(numerator, denominator)
if div > 1 then
numerator = numerator / div
denominator = denominator / div
end
return {
wholestr = (integer > 0) and wholestr or '',
numstr = tostring(numerator),
denstr = tostring(denominator),
value = value,
}
end
return wholestr
end
local function preunits(count, preunit1, preunit2)
-- If count is 1:
-- ignore preunit2
-- return p1
-- else:
-- preunit1 is used for preunit2 if the latter is empty
-- return p1, p2
-- where:
-- p1 is text to insert before the input unit
-- p2 is text to insert before the output unit
-- p1 or p2 may be nil to mean "no preunit"
-- Using '+' gives output like "5+ feet" (no space before, but space after).
local function withspace(text, wantboth)
-- Return text with space before and, if wantboth, after.
-- However, no space is added if there is a space or ' ' or '-'
-- at that position ('-' is for adjectival text).
-- There is also no space if text starts with '&'
-- (e.g. '°' would display a degree symbol with no preceding space).
local char = text:sub(1, 1)
if char == '&' then
return text -- an html entity can be used to specify the exact display
end
if not (char == ' ' or char == '-' or char == '+') then
text = ' ' .. text
end
if wantboth then
char = text:sub(-1, -1)
if not (char == ' ' or char == '-' or text:sub(-6, -1) == ' ') then
text = text .. ' '
end
end
return text
end
local PLUS = '+ '
preunit1 = preunit1 or ''
local trim1 = strip(preunit1)
if count == 1 then
if trim1 == '' then
return nil
end
if trim1 == '+' then
return PLUS
end
return withspace(preunit1, true)
end
preunit1 = withspace(preunit1)
preunit2 = preunit2 or ''
local trim2 = strip(preunit2)
if trim1 == '+' then
if trim2 == '' or trim2 == '+' then
return PLUS, PLUS
end
preunit1 = PLUS
end
if trim2 == '' then
if trim1 == '' then
return nil, nil
end
preunit2 = preunit1
elseif trim2 == '+' then
preunit2 = PLUS
elseif trim2 == ' ' then -- trick to make preunit2 empty
preunit2 = nil
else
preunit2 = withspace(preunit2)
end
return preunit1, preunit2
end
local function range_text(range, want_name, parms, before, after, inout, options)
-- Return before .. rtext .. after
-- where rtext is the text that separates two values in a range.
local rtext, adj_text, exception
options = options or {}
if type(range) == 'table' then
-- Table must specify range text for ('off' and 'on') or ('input' and 'output'),
-- and may specify range text for 'adj=on',
-- and may specify exception = true.
rtext = range[want_name and 'off' or 'on'] or
range[((inout == 'in') == (parms.opt_flip == true)) and 'output' or 'input']
adj_text = range['adj']
exception = range['exception']
else
rtext = range
end
if parms.opt_adjectival then
if want_name or (exception and parms.abbr_org == 'on') then
rtext = adj_text or rtext:gsub(' ', '-'):gsub(' ', '-')
end
end
if rtext == '–' and (options.spaced or after:sub(1, #MINUS) == MINUS) then
rtext = ' – '
end
return before .. rtext .. after
end
local function get_composite(parms, iparm, in_unit_table)
-- Look for a composite input unit. For example, {{convert|1|yd|2|ft|3|in}}
-- would result in a call to this function with
-- iparm = 3 (parms[iparm] = "2", just after the first unit)
-- in_unit_table = (unit table for "yd"; contains value 1 for number of yards)
-- Return true, iparm, unit where
-- iparm = index just after the composite units (7 in above example)
-- unit = composite unit table holding all input units,
-- or return true if no composite unit is present in parms,
-- or return false, t where t is an error message table.
local default, subinfo
local composite_units, count = { in_unit_table }, 1
local fixups = {}
local total = in_unit_table.valinfo[1].value
local subunit = in_unit_table
while subunit.subdivs do -- subdivs is nil or a table of allowed subdivisions
local subcode = strip(parms[iparm+1])
local subdiv = subunit.subdivs[subcode] or subunit.subdivs[(all_units[subcode] or {}).target]
if not subdiv then
break
end
local success
success, subunit = lookup(parms, subcode, 'no_combination')
if not success then return false, subunit end -- should never occur
success, subinfo = extract_number(parms, parms[iparm])
if not success then return false, subinfo end
iparm = iparm + 2
subunit.inout = 'in'
subunit.valinfo = { subinfo }
-- Recalculate total as a number of subdivisions.
-- subdiv[1] = number of subdivisions per previous unit (integer > 1).
total = total * subdiv[1] + subinfo.value
if not default then -- set by the first subdiv with a default defined
default = subdiv.default
end
count = count + 1
composite_units[count] = subunit
if subdiv.unit or subdiv.name then
fixups[count] = { unit = subdiv.unit, name = subdiv.name, valinfo = subunit.valinfo }
end
end
if count == 1 then
return true -- no error and no composite unit
end
for i, fixup in pairs(fixups) do
local unit = fixup.unit
local name = fixup.name
if not unit or (count > 2 and name) then
composite_units[i].fixed_name = name
else
local success, alternate = lookup(parms, unit, 'no_combination')
if not success then return false, alternate end -- should never occur
alternate.inout = 'in'
alternate.valinfo = fixup.valinfo
composite_units[i] = alternate
end
end
return true, iparm, {
utype = in_unit_table.utype,
scale = subunit.scale, -- scale of last (least significant) unit
valinfo = { { value = total, clean = subinfo.clean, denominator = subinfo.denominator } },
composite = composite_units,
default = default or in_unit_table.default
}
end
local function translate_parms(parms, kv_pairs)
-- Update fields in parms by translating each key:value in kv_pairs to terms
-- used by this module (may involve translating from local language to English).
-- Also, checks are performed which may display warnings, if enabled.
-- Return true if successful or return false, t where t is an error message table.
currency_text = nil -- local testing can hold module in memory; must clear globals
if kv_pairs.adj and kv_pairs.sing then
-- For enwiki (before translation), warn if attempt to use adj and sing
-- as the latter is a deprecated alias for the former.
if kv_pairs.adj ~= kv_pairs.sing and kv_pairs.sing ~= '' then
add_warning(parms, 1, 'cvt_unknown_option', 'sing=' .. kv_pairs.sing)
end
kv_pairs.sing = nil
end
kv_pairs.comma = kv_pairs.comma or config.comma -- for plwiki who want default comma=5
for loc_name, loc_value in pairs(kv_pairs) do
local en_name = text_code.en_option_name[loc_name]
if en_name then
local en_value = text_code.en_option_value[en_name]
if en_value == 'INTEGER' then -- altitude_ft, altitude_m, frac, sigfig
en_value = nil
if loc_value == '' then
add_warning(parms, 2, 'cvt_empty_option', loc_name)
else
local minimum
local number, is_integer = get_number(loc_value)
if en_name == 'sigfig' then
minimum = 1
elseif en_name == 'frac' then
minimum = 2
if number and number < 0 then
parms.opt_fraction_horizontal = true
number = -number
end
else
minimum = -1e6
end
if number and is_integer and number >= minimum then
en_value = number
else
local m
if en_name == 'frac' then
m = 'cvt_bad_frac'
elseif en_name == 'sigfig' then
m = 'cvt_bad_sigfig'
else
m = 'cvt_bad_altitude'
end
add_warning(parms, 1, m, loc_name .. '=' .. loc_value)
end
end
elseif en_value == 'TEXT' then -- $, input, qid, qual, stylein, styleout, tracking
en_value = loc_value ~= '' and loc_value or nil -- accept non-empty user text with no validation
if not en_value and (en_name == '$' or en_name == 'qid' or en_name == 'qual') then
add_warning(parms, 2, 'cvt_empty_option', loc_name)
elseif en_name == '$' then
-- Value should be a single character like "€" for the euro currency symbol, but anything is accepted.
currency_text = (loc_value == 'euro') and '€' or loc_value
elseif en_name == 'input' then
-- May have something like {{convert|input=}} (empty input) if source is an infobox
-- with optional fields. In that case, want to output nothing rather than an error.
parms.input_text = loc_value -- keep input because parms.input is nil if loc_value == ''
end
else
en_value = en_value[loc_value]
if en_value and en_value:sub(-1) == '?' then
en_value = en_value:sub(1, -2)
add_warning(parms, -1, 'cvt_deprecated', loc_name .. '=' .. loc_value)
end
if en_value == nil then
if loc_value == '' then
add_warning(parms, 2, 'cvt_empty_option', loc_name)
else
add_warning(parms, 1, 'cvt_unknown_option', loc_name .. '=' .. loc_value)
end
elseif en_value == '' then
en_value = nil -- an ignored option like adj=off
elseif type(en_value) == 'string' and en_value:sub(1, 4) == 'opt_' then
for _, v in ipairs(split(en_value, ',')) do
local lhs, rhs = v:match('^(.-)=(.+)$')
if rhs then
parms[lhs] = tonumber(rhs) or rhs
else
parms[v] = true
end
end
en_value = nil
end
end
parms[en_name] = en_value
else
add_warning(parms, 1, 'cvt_unknown_option', loc_name .. '=' .. loc_value)
end
end
local abbr_entered = parms.abbr
local cfg_abbr = config.abbr
if cfg_abbr then
-- Don't warn if invalid because every convert would show that warning.
if cfg_abbr == 'on always' then
parms.abbr = 'on'
elseif cfg_abbr == 'off always' then
parms.abbr = 'off'
elseif parms.abbr == nil then
if cfg_abbr == 'on default' then
parms.abbr = 'on'
elseif cfg_abbr == 'off default' then
parms.abbr = 'off'
end
end
end
if parms.abbr then
if parms.abbr == 'unit' then
parms.abbr = 'on'
parms.number_word = true
end
parms.abbr_org = parms.abbr -- original abbr, before any flip
elseif parms.opt_hand_hh then
parms.abbr_org = 'on'
parms.abbr = 'on'
else
parms.abbr = 'out' -- default is to abbreviate output only (use symbol, not name)
end
if parms.opt_order_out then
-- Disable options that do not work in a useful way with order=out.
parms.opt_flip = nil -- override adj=flip
parms.opt_spell_in = nil
parms.opt_spell_out = nil
parms.opt_spell_upper = nil
end
if parms.opt_spell_out and not abbr_entered then
parms.abbr = 'off' -- should show unit name when spelling the output value
end
if parms.opt_flip then
local function swap_in_out(option)
local value = parms[option]
if value == 'in' then
parms[option] = 'out'
elseif value == 'out' then
parms[option] = 'in'
end
end
swap_in_out('abbr')
swap_in_out('lk')
if parms.opt_spell_in and not parms.opt_spell_out then
-- For simplicity, and because it does not appear to be needed,
-- user cannot set an option to spell the output only.
parms.opt_spell_in = nil
parms.opt_spell_out = true
end
end
if parms.opt_spell_upper then
parms.spell_upper = parms.opt_flip and 'out' or 'in'
end
if parms.opt_table or parms.opt_tablecen then
if abbr_entered == nil and parms.lk == nil then
parms.opt_values = true
end
parms.table_align = parms.opt_table and 'right' or 'center'
end
if parms.table_align or parms.opt_sortable_on then
parms.need_table_or_sort = true
end
local disp_joins = text_code.disp_joins
local default_joins = disp_joins['b']
parms.join_between = default_joins[3] or '; '
local disp = parms.disp
if disp == nil then -- special case for the most common setting
parms.joins = default_joins
elseif disp == 'x' then
-- Later, parms.joins is set from the input parameters.
else
-- Old template does this.
local abbr = parms.abbr
if disp == 'slash' then
if abbr_entered == nil then
disp = 'slash-nbsp'
elseif abbr == 'in' or abbr == 'out' then
disp = 'slash-sp'
else
disp = 'slash-nosp'
end
elseif disp == 'sqbr' then
if abbr == 'on' then
disp = 'sqbr-nbsp'
else
disp = 'sqbr-sp'
end
end
parms.joins = disp_joins[disp] or default_joins
parms.join_between = parms.joins[3] or parms.join_between
parms.wantname = parms.joins.wantname
end
if (en_default and not parms.opt_lang_local and (parms[1] or ''):find('%d')) or parms.opt_lang_en then
from_en_table = nil
end
if en_default and from_en_table then
-- For hiwiki: localized symbol/name is defined with the US symbol/name field,
-- and is used if output uses localized numbers.
parms.opt_sp_us = true
end
return true
end
local function get_values(parms)
-- If successful, update parms and return true, v, i where
-- v = table of input values
-- i = index to next entry in parms after those processed here
-- or return false, t where t is an error message table.
local valinfo = collection() -- numbered table of input values
local range = collection() -- numbered table of range items (having, for example, 2 range items requires 3 input values)
local had_nocomma -- true if removed "nocomma" kludge from second parameter (like "tonocomma")
local parm2 = strip(parms[2])
if parm2 and parm2:sub(-7, -1) == 'nocomma' then
parms[2] = strip(parm2:sub(1, -8))
parms.opt_nocomma = true
had_nocomma = true
end
local function extractor(i)
-- If the parameter is not a value, try unpacking it as a range ("1-23" for "1 to 23").
-- However, "-1-2/3" is a negative fraction (-1⅔), so it must be extracted first.
-- Do not unpack a parameter if it is like "3-1/2" which is sometimes incorrectly
-- used instead of "3+1/2" (and which should not be interpreted as "3 to ½").
-- Unpacked items are inserted into the parms table.
-- The tail recursion allows combinations like "1x2 to 3x4".
local valstr = strip(parms[i]) -- trim so any '-' as a negative sign will be at start
local success, result = extract_number(parms, valstr, i > 1)
if not success and valstr and i < 20 then -- check i to limit abuse
local lhs, sep, rhs = valstr:match('^(%S+)%s+(%S+)%s+(%S.*)')
if lhs and not (sep == '-' and rhs:match('/')) then
if sep:find('%d') then
return success, result -- to reject {{convert|1 234 567|m}} with a decent message (en only)
end
parms[i] = rhs
table.insert(parms, i, sep)
table.insert(parms, i, lhs)
return extractor(i)
end
if not valstr:match('%-.*/') then
for _, sep in ipairs(text_code.ranges.words) do
local start, stop = valstr:find(sep, 2, true) -- start at 2 to skip any negative sign for range '-'
if start then
parms[i] = valstr:sub(stop + 1)
table.insert(parms, i, sep)
table.insert(parms, i, valstr:sub(1, start - 1))
return extractor(i)
end
end
end
end
return success, result
end
local i = 1
local is_change
while true do
local success, info = extractor(i) -- need to set parms.opt_nocomma before calling this
if not success then return false, info end
i = i + 1
if is_change then
info.is_change = true -- value is after "±" and so is a change (significant for range like {{convert|5|±|5|°C}})
is_change = nil
end
valinfo:add(info)
local range_item = get_range(strip(parms[i]))
if not range_item then
break
end
i = i + 1
range:add(range_item)
if type(range_item) == 'table' then
-- For range "x", if append unit to some values, append it to all.
parms.in_range_x = parms.in_range_x or range_item.in_range_x
parms.out_range_x = parms.out_range_x or range_item.out_range_x
parms.abbr_range_x = parms.abbr_range_x or range_item.abbr_range_x
is_change = range_item.is_range_change
end
end
if range.n > 0 then
if range.n > 30 then -- limit abuse, although 4 is a more likely upper limit
return false, { 'cvt_invalid_num' } -- misleading message but it will do
end
parms.range = range
elseif had_nocomma then
return false, { 'cvt_unknown', parm2 }
end
return true, valinfo, i
end
local function simple_get_values(parms)
-- If input is like "{{convert|valid_value|valid_unit|...}}",
-- return true, i, in_unit, in_unit_table
-- i = index in parms of what follows valid_unit, if anything.
-- The valid_value is not negative and does not use a fraction, and
-- no options requiring further processing of the input are used.
-- Otherwise, return nothing or return false, parm1 for caller to interpret.
-- Testing shows this function is successful for 96% of converts in articles,
-- and that on average it speeds up converts by 8%.
local clean = to_en(strip(parms[1] or ''), parms)
if parms.opt_ri or parms.opt_spell_in or #clean > 10 or not clean:match('^[0-9.]+$') then
return false, clean
end
local value = tonumber(clean)
if not value then return end
local info = {
value = value,
altvalue = value,
singular = (value == 1),
clean = clean,
show = with_separator(parms, clean),
}
local in_unit = strip(parms[2])
local success, in_unit_table = lookup(parms, in_unit, 'no_combination')
if not success then return end
in_unit_table.valinfo = { info }
return true, 3, in_unit, in_unit_table
end
local function wikidata_call(parms, operation, ...)
-- Return true, s where s is the result of a Wikidata operation,
-- or return false, t where t is an error message table.
local function worker(...)
wikidata_code = wikidata_code or require(wikidata_module)
wikidata_data = wikidata_data or mw.loadData(wikidata_data_module)
return wikidata_code[operation](wikidata_data, ...)
end
local success, status, result = pcall(worker, ...)
if success then
return status, result
end
if parms.opt_sortable_debug then
-- Use debug=yes to crash if an error while accessing Wikidata.
error('Error accessing Wikidata: ' .. status, 0)
end
return false, { 'cvt_wd_fail' }
end
local function get_parms(parms, args)
-- If successful, update parms and return true, unit where
-- parms is a table of all arguments passed to the template
-- converted to named arguments, and
-- unit is the input unit table;
-- or return false, t where t is an error message table.
-- For special processing (not a convert), can also return
-- true, wikitext where wikitext is the final result.
-- The returned input unit table may be for a fake unit using the specified
-- unit code as the symbol and name, and with bad_mcode = message code table.
-- MediaWiki removes leading and trailing whitespace from the values of
-- named arguments. However, the values of numbered arguments include any
-- whitespace entered in the template, and whitespace is used by some
-- parameters (example: the numbered parameters associated with "disp=x").
local kv_pairs = {} -- table of input key:value pairs where key is a name; needed because cannot iterate parms and add new fields to it
for k, v in pairs(args) do
if type(k) == 'number' or k == 'test' then -- parameter "test" is reserved for testing and is not translated
parms[k] = v
else
kv_pairs[k] = v
end
end
if parms.test == 'wikidata' then
local ulookup = function (ucode)
-- Use empty table for parms so it does not accumulate results when used repeatedly.
return lookup({}, ucode, 'no_combination')
end
return wikidata_call(parms, '_listunits', ulookup)
end
local success, msg = translate_parms(parms, kv_pairs)
if not success then return false, msg end
if parms.input then
success, msg = wikidata_call(parms, '_adjustparameters', parms, 1)
if not success then return false, msg end
end
local success, i, in_unit, in_unit_table = simple_get_values(parms)
if not success then
if type(i) == 'string' and i:match('^NNN+$') then
-- Some infoboxes have examples like {{convert|NNN|m}} (3 or more "N").
-- Output an empty string for these.
return false, { 'cvt_no_output' }
end
local valinfo
success, valinfo, i = get_values(parms)
if not success then return false, valinfo end
in_unit = strip(parms[i])
i = i + 1
success, in_unit_table = lookup(parms, in_unit, 'no_combination')
if not success then
in_unit = in_unit or ''
if parms.opt_ignore_error then -- display given unit code with no error (for use with {{val}})
in_unit_table = '' -- suppress error message and prevent processing of output unit
end
in_unit_table = setmetatable({
symbol = in_unit, name2 = in_unit, utype = in_unit,
scale = 1, default = '', defkey = '', linkey = '',
bad_mcode = in_unit_table }, unit_mt)
end
in_unit_table.valinfo = valinfo
end
if parms.test == 'msg' then
-- Am testing the messages produced when no output unit is specified, and
-- the input unit has a missing or invalid default.
-- Set two units for testing that.
-- LATER: Remove this code.
if in_unit == 'chain' then
in_unit_table.default = nil -- no default
elseif in_unit == 'rd' then
in_unit_table.default = "ft!X!m" -- an invalid expression
end
end
in_unit_table.inout = 'in' -- this is an input unit
if not parms.range then
local success, inext, composite_unit = get_composite(parms, i, in_unit_table)
if not success then return false, inext end
if composite_unit then
in_unit_table = composite_unit
i = inext
end
end
if in_unit_table.builtin == 'mach' then
-- As with old template, a number following Mach as the input unit is the altitude.
-- That is deprecated: should use altitude_ft=NUMBER or altitude_m=NUMBER.
local success, info
success = tonumber(parms[i]) -- this will often work and will give correct result for values like 2e4 without forcing output scientific notation
if success then
info = { value = success }
else
success, info = extract_number(parms, parms[i], false, true)
end
if success then
i = i + 1
in_unit_table.altitude = info.value
end
end
local word = strip(parms[i])
i = i + 1
local precision, is_bad_precision
local function set_precision(text)
local number, is_integer = get_number(text)
if number then
if is_integer then
precision = number
else
precision = text
is_bad_precision = true
end
return true -- text was used for precision, good or bad
end
end
if word and not set_precision(word) then
parms.out_unit = parms.out_unit or word
if set_precision(strip(parms[i])) then
i = i + 1
end
end
if parms.opt_adj_mid then
word = parms[i]
i = i + 1
if word then -- mid-text words
if word:sub(1, 1) == '-' then
parms.mid = word
else
parms.mid = ' ' .. word
end
end
end
if parms.opt_one_preunit then
parms[parms.opt_flip and 'preunit2' or 'preunit1'] = preunits(1, parms[i])
i = i + 1
end
if parms.disp == 'x' then
-- Following is reasonably compatible with the old template.
local first = parms[i] or ''
local second = parms[i+1] or ''
i = i + 2
if strip(first) == '' then -- user can enter ' ' rather than ' ' to avoid the default
first = ' [ ' .. first
second = ' ]' .. second
end
parms.joins = { first, second }
elseif parms.opt_two_preunits then
local p1, p2 = preunits(2, parms[i], parms[i+1])
i = i + 2
if parms.preunit1 then
-- To simplify documentation, allow unlikely use of adj=pre with disp=preunit
-- (however, an output unit must be specified with adj=pre and with disp=preunit).
parms.preunit1 = parms.preunit1 .. p1
parms.preunit2 = p2
else
parms.preunit1, parms.preunit2 = p1, p2
end
end
if precision == nil then
if set_precision(strip(parms[i])) then
i = i + 1
end
end
if is_bad_precision then
add_warning(parms, 1, 'cvt_bad_prec', precision)
else
parms.precision = precision
end
for j = i, i + 3 do
local parm = parms[j] -- warn if find a non-empty extraneous parameter
if parm and parm:match('%S') then
add_warning(parms, 1, 'cvt_unknown_option', parm)
break
end
end
return true, in_unit_table
end
local function record_default_precision(parms, out_current, precision)
-- If necessary, adjust parameters and return a possibly adjusted precision.
-- When converting a range of values where a default precision is required,
-- that default is calculated for each value because the result sometimes
-- depends on the precise input and output values. This function may cause
-- the entire convert process to be repeated in order to ensure that the
-- same default precision is used for each individual convert.
-- If that were not done, a range like 1000 to 1000.4 may give poor results
-- because the first output could be heavily rounded, while the second is not.
-- For range 1000.4 to 1000, this function can give the second convert the
-- same default precision that was used for the first.
if not parms.opt_round_each then
local maxdef = out_current.max_default_precision
if maxdef then
if maxdef < precision then
parms.do_convert_again = true
out_current.max_default_precision = precision
else
precision = out_current.max_default_precision
end
else
out_current.max_default_precision = precision
end
end
return precision
end
local function default_precision(parms, invalue, inclean, denominator, outvalue, in_current, out_current, extra)
-- Return a default value for precision (an integer like 2, 0, -2).
-- If denominator is not nil, it is the value of the denominator in inclean.
-- Code follows procedures used in old template.
local fudge = 1e-14 -- {{Order of magnitude}} adds this, so we do too
local prec, minprec, adjust
local subunit_ignore_trailing_zero
local subunit_more_precision -- kludge for "in" used in input like "|2|ft|6|in"
local composite = in_current.composite
if composite then
subunit_ignore_trailing_zero = true -- input "|2|st|10|lb" has precision 0, not -1
if composite[#composite].exception == 'subunit_more_precision' then
subunit_more_precision = true -- do not use standard precision with input like "|2|ft|6|in"
end
end
if denominator and denominator > 0 then
prec = math.max(log10(denominator), 1)
else
-- Count digits after decimal mark, handling cases like '12.345e6'.
local exponent
local integer, dot, decimals, expstr = inclean:match('^(%d*)(%.?)(%d*)(.*)')
local e = expstr:sub(1, 1)
if e == 'e' or e == 'E' then
exponent = tonumber(expstr:sub(2))
end
if dot == '' then
prec = subunit_ignore_trailing_zero and 0 or -integer:match('0*$'):len()
else
prec = #decimals
end
if exponent then
-- So '1230' and '1.23e3' both give prec = -1, and '0.00123' and '1.23e-3' give 5.
prec = prec - exponent
end
end
if in_current.istemperature and out_current.istemperature then
-- Converting between common temperatures (°C, °F, °R, K); not keVT.
-- Kelvin value can be almost zero, or small but negative due to precision problems.
-- Also, an input value like -300 C (below absolute zero) gives negative kelvins.
-- Calculate minimum precision from absolute value.
adjust = 0
local kelvin = abs((invalue - in_current.offset) * in_current.scale)
if kelvin < 1e-8 then -- assume nonzero due to input or calculation precision problem
minprec = 2
else
minprec = 2 - floor(log10(kelvin) + fudge) -- 3 sigfigs in kelvin
end
else
if invalue == 0 or outvalue <= 0 then
-- We are never called with a negative outvalue, but it might be zero.
-- This is special-cased to avoid calculation exceptions.
return record_default_precision(parms, out_current, 0)
end
if out_current.exception == 'integer_more_precision' and floor(invalue) == invalue then
-- With certain output units that sometimes give poor results
-- with default rounding, use more precision when the input
-- value is equal to an integer. An example of a poor result
-- is when input 50 gives a smaller output than input 49.5.
-- Experiment shows this helps, but it does not eliminate all
-- surprises because it is not clear whether "50" should be
-- interpreted as "from 45 to 55" or "from 49.5 to 50.5".
adjust = -log10(in_current.scale)
elseif subunit_more_precision then
-- Conversion like "{{convert|6|ft|1|in|cm}}" (where subunit is "in")
-- has a non-standard adjust value, to give more output precision.
adjust = log10(out_current.scale) + 2
else
adjust = log10(abs(invalue / outvalue))
end
adjust = adjust + log10(2)
-- Ensure that the output has at least two significant figures.
minprec = 1 - floor(log10(outvalue) + fudge)
end
if extra then
adjust = extra.adjust or adjust
minprec = extra.minprec or minprec
end
return record_default_precision(parms, out_current, math.max(floor(prec + adjust), minprec))
end
local function convert(parms, invalue, info, in_current, out_current)
-- Convert given input value from one unit to another.
-- Return output_value (a number) if a simple convert, or
-- return f, t where
-- f = true, t = table of information with results, or
-- f = false, t = error message table.
local inscale = in_current.scale
local outscale = out_current.scale
if not in_current.iscomplex and not out_current.iscomplex then
return invalue * (inscale / outscale) -- minimize overhead for most common case
end
if in_current.invert or out_current.invert then
-- Inverted units, such as inverse length, inverse time, or
-- fuel efficiency. Built-in units do not have invert set.
if (in_current.invert or 1) * (out_current.invert or 1) < 0 then
return 1 / (invalue * inscale * outscale)
end
return invalue * (inscale / outscale)
elseif in_current.offset then
-- Temperature (there are no built-ins for this type of unit).
if info.is_change then
return invalue * (inscale / outscale)
end
return (invalue - in_current.offset) * (inscale / outscale) + out_current.offset
else
-- Built-in unit.
local in_builtin = in_current.builtin
local out_builtin = out_current.builtin
if in_builtin and out_builtin then
if in_builtin == out_builtin then
return invalue
end
-- There are no cases (yet) where need to convert from one
-- built-in unit to another, so this should never occur.
return false, { 'cvt_bug_convert' }
end
if in_builtin == 'mach' or out_builtin == 'mach' then
-- Should check that only one altitude is given but am planning to remove
-- in_current.altitude (which can only occur when Mach is the input unit),
-- and out_current.altitude cannot occur.
local alt = parms.altitude_ft or in_current.altitude
if not alt and parms.altitude_m then
alt = parms.altitude_m / 0.3048 -- 1 ft = 0.3048 m
end
local spd = speed_of_sound(alt)
if in_builtin == 'mach' then
inscale = spd
return invalue * (inscale / outscale)
end
outscale = spd
local adjust = 0.1 / inscale
return true, {
outvalue = invalue * (inscale / outscale),
adjust = log10(adjust) + log10(2),
}
elseif in_builtin == 'hand' then
-- 1 hand = 4 inches; 1.2 hands = 6 inches.
-- Decimals of a hand are only defined for the first digit, and
-- the first fractional digit should be a number of inches (1, 2 or 3).
-- However, this code interprets the entire fractional part as the number
-- of inches / 10 (so 1.75 inches would be 0.175 hands).
-- A value like 12.3 hands is exactly 12*4 + 3 inches; base default precision on that.
local integer, fracpart = math.modf(invalue)
local inch_value = 4 * integer + 10 * fracpart -- equivalent number of inches
local factor = inscale / outscale
if factor == 4 then
-- Am converting to inches: show exact result, and use "inches" not "in" by default.
if parms.abbr_org == nil then
out_current.usename = true
end
local show = format('%g', abs(inch_value)) -- show and clean are unsigned
if not show:find('e', 1, true) then
return true, {
invalue = inch_value,
outvalue = inch_value,
clean = show,
show = show,
}
end
end
local outvalue = (integer + 2.5 * fracpart) * factor
local fracstr = info.clean:match('%.(.*)') or ''
local fmt
if fracstr == '' then
fmt = '%.0f'
else
fmt = '%.' .. format('%d', #fracstr - 1) .. 'f'
end
return true, {
invalue = inch_value,
clean = format(fmt, inch_value),
outvalue = outvalue,
minprec = 0,
}
end
end
return false, { 'cvt_bug_convert' } -- should never occur
end
local function user_style(parms, i)
-- Return text for a user-specified style for a table cell, or '' if none,
-- given i = 1 (input style) or 2 (output style).
local style = parms[(i == 1) and 'stylein' or 'styleout']
if style then
style = style:gsub('"', '')
if style ~= '' then
if style:sub(-1) ~= ';' then
style = style .. ';'
end
return style
end
end
return ''
end
local function make_table_or_sort(parms, invalue, info, in_current, scaled_top)
-- Set options to handle output for a table or a sort key, or both.
-- The text sort key is based on the value resulting from converting
-- the input to a fake base unit with scale = 1, and other properties
-- required for a conversion derived from the input unit.
-- For other modules, return the sort key in a hidden span element, and
-- the scaled value used to generate the sort key.
-- If scaled_top is set, it is the scaled value of the numerator of a per unit
-- to be combined with this unit (the denominator) to make the sort key.
-- Scaling only works with units that convert with a factor (not temperature).
local sortkey, scaled_value
if parms.opt_sortable_on then
local base = { -- a fake unit with enough fields for a valid convert
scale = 1,
invert = in_current.invert and 1,
iscomplex = in_current.iscomplex,
offset = in_current.offset and 0,
}
local outvalue, extra = convert(parms, invalue, info, in_current, base)
if extra then
outvalue = extra.outvalue
end
if in_current.istemperature then
-- Have converted to kelvin; assume numbers close to zero have a
-- rounding error and should be zero.
if abs(outvalue) < 1e-12 then
outvalue = 0
end
end
if scaled_top and outvalue ~= 0 then
outvalue = scaled_top / outvalue
end
scaled_value = outvalue
if not valid_number(outvalue) then
if outvalue < 0 then
sortkey = '1000000000000000000'
else
sortkey = '9000000000000000000'
end
elseif outvalue == 0 then
sortkey = '5000000000000000000'
else
local mag = floor(log10(abs(outvalue)) + 1e-14)
local prefix
if outvalue > 0 then
prefix = 7000 + mag
else
prefix = 2999 - mag
outvalue = outvalue + 10^(mag+1)
end
sortkey = format('%d', prefix) .. format('%015.0f', floor(outvalue * 10^(14-mag)))
end
end
local sortspan
if sortkey and not parms.table_align then
sortspan = parms.opt_sortable_debug and
'<span data-sort-value="' .. sortkey .. '♠"><span style="border:1px solid">' .. sortkey .. '♠</span></span>' or
'<span data-sort-value="' .. sortkey .. '♠"></span>'
parms.join_before = sortspan
end
if parms.table_align then
local sort
if sortkey then
sort = ' data-sort-value="' .. sortkey .. '"'
if parms.opt_sortable_debug then
parms.join_before = '<span style="border:1px solid">' .. sortkey .. '</span>'
end
else
sort = ''
end
local style = 'style="text-align:' .. parms.table_align .. ';'
local joins = {}
for i = 1, 2 do
joins[i] = (i == 1 and '' or '\n|') .. style .. user_style(parms, i) .. '"' .. sort .. '|'
end
parms.table_joins = joins
end
return sortspan, scaled_value
end
local cvt_to_hand
local function cvtround(parms, info, in_current, out_current)
-- Return true, t where t is a table with the conversion results; fields:
-- show = rounded, formatted string with the result of converting value in info,
-- using the rounding specified in parms.
-- singular = true if result (after rounding and ignoring any negative sign)
-- is "1", or like "1.00", or is a fraction with value < 1;
-- (and more fields shown below, and a calculated 'absvalue' field).
-- or return false, t where t is an error message table.
-- Input info.clean uses en digits (it has been translated, if necessary).
-- Output show uses en or non-en digits as appropriate, or can be spelled.
if out_current.builtin == 'hand' then
return cvt_to_hand(parms, info, in_current, out_current)
end
local invalue = in_current.builtin == 'hand' and info.altvalue or info.value
local outvalue, extra = convert(parms, invalue, info, in_current, out_current)
if parms.need_table_or_sort then
parms.need_table_or_sort = nil -- process using first input value only
make_table_or_sort(parms, invalue, info, in_current)
end
if extra then
if not outvalue then return false, extra end
invalue = extra.invalue or invalue
outvalue = extra.outvalue
end
if not valid_number(outvalue) then
return false, { 'cvt_invalid_num' }
end
local isnegative
if outvalue < 0 then
isnegative = true
outvalue = -outvalue
end
local precision, show, exponent
local denominator = out_current.frac
if denominator then
show = fraction_table(outvalue, denominator)
else
precision = parms.precision
if not precision then
if parms.sigfig then
show, exponent = make_sigfig(outvalue, parms.sigfig)
elseif parms.opt_round then
local n = parms.opt_round
if n == 0.5 then
local integer, fracpart = math.modf(floor(2 * outvalue + 0.5) / 2)
if fracpart == 0 then
show = format('%.0f', integer)
else
show = format('%.1f', integer + fracpart)
end
else
show = format('%.0f', floor((outvalue / n) + 0.5) * n)
end
elseif in_current.builtin == 'mach' then
local sigfig = info.clean:gsub('^[0.]+', ''):gsub('%.', ''):len() + 1
show, exponent = make_sigfig(outvalue, sigfig)
else
local inclean = info.clean
if extra then
inclean = extra.clean or inclean
show = extra.show
end
if not show then
precision = default_precision(parms, invalue, inclean, info.denominator, outvalue, in_current, out_current, extra)
end
end
end
end
if precision then
if precision >= 0 then
local fudge
if precision <= 8 then
-- Add a fudge to handle common cases of bad rounding due to inability
-- to precisely represent some values. This makes the following work:
-- {{convert|-100.1|C|K}} and {{convert|5555000|um|m|2}}.
-- Old template uses #expr round, which invokes PHP round().
-- LATER: Investigate how PHP round() works.
fudge = 2e-14
else
fudge = 0
end
local fmt = '%.' .. format('%d', precision) .. 'f'
local success
success, show = pcall(format, fmt, outvalue + fudge)
if not success then
return false, { 'cvt_big_prec', tostring(precision) }
end
else
precision = -precision -- #digits to zero (in addition to any digits after dot)
local shift = 10 ^ precision
show = format('%.0f', outvalue/shift)
if show ~= '0' then
exponent = #show + precision
end
end
end
local t = format_number(parms, show, exponent, isnegative)
if type(show) == 'string' then
-- Set singular using match because on some systems 0.99999999999999999 is 1.0.
if exponent then
t.singular = (exponent == 1 and show:match('^10*$'))
else
t.singular = (show == '1' or show:match('^1%.0*$'))
end
else
t.fraction_table = show
t.singular = (outvalue <= 1) -- cannot have 'fraction == 1', but if it were possible it would be singular
end
t.raw_absvalue = outvalue -- absolute value before rounding
return true, setmetatable(t, {
__index = function (self, key)
if key == 'absvalue' then
-- Calculate absolute value after rounding, if needed.
local clean, exponent = rawget(self, 'clean'), rawget(self, 'exponent')
local value = tonumber(clean) -- absolute value (any negative sign has been ignored)
if exponent then
value = value * 10^exponent
end
rawset(self, key, value)
return value
end
end })
end
function cvt_to_hand(parms, info, in_current, out_current)
-- Convert input to hands, inches.
-- Return true, t where t is a table with the conversion results;
-- or return false, t where t is an error message table.
if parms.abbr_org == nil then
out_current.usename = true -- default is to show name not symbol
end
local precision = parms.precision
local frac = out_current.frac
if not frac and precision and precision > 1 then
frac = (precision == 2) and 2 or 4
end
local out_next = out_current.out_next
if out_next then
-- Use magic knowledge to determine whether the next unit is inches without requiring i18n.
-- The following ensures that when the output combination "hand in" is used, the inches
-- value is rounded to match the hands value. Also, displaying say "61½" instead of 61.5
-- is better as 61.5 implies the value is not 61.4.
if out_next.exception == 'subunit_more_precision' then
out_next.frac = frac
end
end
-- Convert to inches; calculate hands from that.
local dummy_unit_table = { scale = out_current.scale / 4, frac = frac }
local success, outinfo = cvtround(parms, info, in_current, dummy_unit_table)
if not success then return false, outinfo end
local tfrac = outinfo.fraction_table
local inches = outinfo.raw_absvalue
if tfrac then
inches = floor(inches) -- integer part only; fraction added later
else
inches = floor(inches + 0.5) -- a hands measurement never shows decimals of an inch
end
local hands, inches = divide(inches, 4)
outinfo.absvalue = hands + inches/4 -- supposed to be the absolute rounded value, but this is close enough
local inchstr = tostring(inches) -- '0', '1', '2' or '3'
if precision and precision <= 0 then -- using negative or 0 for precision rounds to nearest hand
hands = floor(outinfo.raw_absvalue/4 + 0.5)
inchstr = ''
elseif tfrac then
-- Always show an integer before fraction (like "15.0½") because "15½" means 15-and-a-half hands.
inchstr = numdot .. format_fraction(parms, 'out', false, inchstr, tfrac.numstr, tfrac.denstr)
else
inchstr = numdot .. from_en(inchstr)
end
outinfo.show = outinfo.sign .. with_separator(parms, format('%.0f', hands)) .. inchstr
return true, outinfo
end
local function evaluate_condition(value, condition)
-- Return true or false from applying a conditional expression to value,
-- or throw an error if invalid.
-- A very limited set of expressions is supported:
-- v < 9
-- v * 9 < 9
-- where
-- 'v' is replaced with value
-- 9 is any number (as defined by Lua tonumber)
-- only en digits are accepted
-- '<' can also be '<=' or '>' or '>='
-- In addition, the following form is supported:
-- LHS and RHS
-- where
-- LHS, RHS = any of above expressions.
local function compare(value, text)
local arithop, factor, compop, limit = text:match('^%s*v%s*([*]?)(.-)([<>]=?)(.*)$')
if arithop == nil then
error('Invalid default expression', 0)
elseif arithop == '*' then
factor = tonumber(factor)
if factor == nil then
error('Invalid default expression', 0)
end
value = value * factor
end
limit = tonumber(limit)
if limit == nil then
error('Invalid default expression', 0)
end
if compop == '<' then
return value < limit
elseif compop == '<=' then
return value <= limit
elseif compop == '>' then
return value > limit
elseif compop == '>=' then
return value >= limit
end
error('Invalid default expression', 0) -- should not occur
end
local lhs, rhs = condition:match('^(.-%W)and(%W.*)')
if lhs == nil then
return compare(value, condition)
end
return compare(value, lhs) and compare(value, rhs)
end
local function get_default(value, unit_table)
-- Return true, s where s = name of unit's default output unit,
-- or return false, t where t is an error message table.
-- Some units have a default that depends on the input value
-- (the first value if a range of values is used).
-- If '!' is in the default, the first bang-delimited field is an
-- expression that uses 'v' to represent the input value.
-- Example: 'v < 120 ! small ! big ! suffix' (suffix is optional)
-- evaluates 'v < 120' as a boolean with result
-- 'smallsuffix' if (value < 120), or 'bigsuffix' otherwise.
-- Input must use en digits and '.' decimal mark.
local default = data_code.default_exceptions[unit_table.defkey or unit_table.symbol] or unit_table.default
if not default then
local per = unit_table.per
if per then
local function a_default(v, u)
local success, ucode = get_default(v, u)
if not success then
return '?' -- an unlikely error has occurred; will cause lookup of default to fail
end
-- Attempt to use only the first unit if a combination or output multiple.
-- This is not bulletproof but should work for most cases.
-- Where it does not work, the convert will need to specify the wanted output unit.
local t = all_units[ucode]
if t then
local combo = t.combination
if combo then
-- For a multiple like ftin, the "first" unit (ft) is last in the combination.
local i = t.multiple and table_len(combo) or 1
ucode = combo[i]
end
else
-- Try for an automatically generated combination.
local item = ucode:match('^(.-)%+') or ucode:match('^(%S+)%s')
if all_units[item] then
return item
end
end
return ucode
end
local unit1, unit2 = per[1], per[2]
local def1 = (unit1 and a_default(value, unit1) or unit_table.vprefix or '')
local def2 = a_default(1, unit2) -- 1 because per unit of denominator
return true, def1 .. '/' .. def2
end
return false, { 'cvt_no_default', unit_table.symbol }
end
if default:find('!', 1, true) == nil then
return true, default
end
local t = split(default, '!')
if #t == 3 or #t == 4 then
local success, result = pcall(evaluate_condition, value, t[1])
if success then
default = result and t[2] or t[3]
if #t == 4 then
default = default .. t[4]
end
return true, default
end
end
return false, { 'cvt_bad_default', unit_table.symbol }
end
local linked_pages -- to record linked pages so will not link to the same page more than once
local function unlink(unit_table)
-- Forget that the given unit has previously been linked (if it has).
-- That is needed when processing a range of inputs or outputs when an id
-- for the first range value may have been evaluated, but only an id for
-- the last value is displayed, and that id may need to be linked.
linked_pages[unit_table.unitcode or unit_table] = nil
end
local function make_link(link, id, unit_table)
-- Return wikilink "[[link|id]]", possibly abbreviated as in examples:
-- [[Mile|mile]] --> [[mile]]
-- [[Mile|miles]] --> [[mile]]s
-- However, just id is returned if:
-- * no link given (so caller does not need to check if a link was defined); or
-- * link has previously been used during the current convert (to avoid overlinking).
local link_key
if unit_table then
link_key = unit_table.unitcode or unit_table
else
link_key = link
end
if not link or link == '' or linked_pages[link_key] then
return id
end
linked_pages[link_key] = true
-- Following only works for language en, but it should be safe on other wikis,
-- and overhead of doing it generally does not seem worthwhile.
local l = link:sub(1, 1):lower() .. link:sub(2)
if link == id or l == id then
return '[[' .. id .. ']]'
elseif link .. 's' == id or l .. 's' == id then
return '[[' .. id:sub(1, -2) .. ']]s'
else
return '[[' .. link .. '|' .. id .. ']]'
end
end
local function variable_name(clean, unit_table)
-- For slwiki, a unit name depends on the value.
-- Parameter clean is the unsigned rounded value in en digits, as a string.
-- Value Source Example for "m"
-- integer 1: name1 meter (also is the name of the unit)
-- integer 2: var{1} metra
-- integer 3 and 4: var{2} metri
-- integer else: var{3} metrov (0 and 5 or more)
-- real/fraction: var{4} metra
-- var{i} means the i'th field in unit_table.varname if it exists and has
-- an i'th field, otherwise name2.
-- Fields are separated with "!" and are not empty.
-- A field for a unit using an SI prefix has the prefix name inserted,
-- replacing '#' if found, or before the field otherwise.
local vname
if clean == '1' then
vname = unit_table.name1
elseif unit_table.varname then
local i
if clean == '2' then
i = 1
elseif clean == '3' or clean == '4' then
i = 2
elseif clean:find('.', 1, true) then
i = 4
else
i = 3
end
if i > 1 and varname == 'pl' then
i = i - 1
end
vname = split(unit_table.varname, '!')[i]
end
if vname then
local si_name = rawget(unit_table, 'si_name') or ''
local pos = vname:find('#', 1, true)
if pos then
vname = vname:sub(1, pos - 1) .. si_name .. vname:sub(pos + 1)
else
vname = si_name .. vname
end
return vname
end
return unit_table.name2
end
local function linked_id(parms, unit_table, key_id, want_link, clean)
-- Return final unit id (symbol or name), optionally with a wikilink,
-- and update unit_table.sep if required.
-- key_id is one of: 'symbol', 'sym_us', 'name1', 'name1_us', 'name2', 'name2_us'.
local abbr_on = (key_id == 'symbol' or key_id == 'sym_us')
if abbr_on and want_link then
local symlink = rawget(unit_table, 'symlink')
if symlink then
return symlink -- for exceptions that have the linked symbol built-in
end
end
local multiplier = rawget(unit_table, 'multiplier')
local per = unit_table.per
if per then
local paren1, paren2 = '', '' -- possible parentheses around bottom unit
local unit1 = per[1] -- top unit_table, or nil
local unit2 = per[2] -- bottom unit_table
if abbr_on then
if not unit1 then
unit_table.sep = '' -- no separator in "$2/acre"
end
if not want_link then
local symbol = unit_table.symbol_raw
if symbol then
return symbol -- for exceptions that have the symbol built-in
end
end
if (unit2.symbol):find('⋅', 1, true) then
paren1, paren2 = '(', ')'
end
end
local key_id2 -- unit2 is always singular
if key_id == 'name2' then
key_id2 = 'name1'
elseif key_id == 'name2_us' then
key_id2 = 'name1_us'
else
key_id2 = key_id
end
local result
if abbr_on then
result = '/'
elseif omitsep then
result = per_word
elseif unit1 then
result = ' ' .. per_word .. ' '
else
result = per_word .. ' '
end
if want_link and unit_table.link then
if abbr_on or not varname then
result = (unit1 and linked_id(parms, unit1, key_id, false, clean) or '') .. result .. linked_id(parms, unit2, key_id2, false, '1')
else
result = (unit1 and variable_name(clean, unit1) or '') .. result .. variable_name('1', unit2)
end
if omit_separator(result) then
unit_table.sep = ''
end
return make_link(unit_table.link, result, unit_table)
end
if unit1 then
result = linked_id(parms, unit1, key_id, want_link, clean) .. result
if unit1.sep then
unit_table.sep = unit1.sep
end
elseif omitsep then
unit_table.sep = ''
end
return result .. paren1 .. linked_id(parms, unit2, key_id2, want_link, '1') .. paren2
end
if multiplier then
-- A multiplier (like "100" in "100km") forces the unit to be plural.
multiplier = from_en(multiplier)
if not omitsep then
multiplier = multiplier .. (abbr_on and ' ' or ' ')
end
if not abbr_on then
if key_id == 'name1' then
key_id = 'name2'
elseif key_id == 'name1_us' then
key_id = 'name2_us'
end
end
else
multiplier = ''
end
local id = unit_table.fixed_name or ((varname and not abbr_on) and variable_name(clean, unit_table) or unit_table[key_id])
if omit_separator(id) then
unit_table.sep = ''
end
if want_link then
local link = data_code.link_exceptions[unit_table.linkey or unit_table.symbol] or unit_table.link
if link then
local before = ''
local i = unit_table.customary
if i == 1 and parms.opt_sp_us then
i = 2 -- show "U.S." not "US"
end
if i == 3 and abbr_on then
i = 4 -- abbreviate "imperial" to "imp"
end
local customary = text_code.customary_units[i]
if customary then
-- LATER: This works for language en only, but it's esoteric so ignore for now.
local pertext
if id:sub(1, 1) == '/' then
-- Want unit "/USgal" to display as "/U.S. gal", not "U.S. /gal".
pertext = '/'
id = id:sub(2)
elseif id:sub(1, 4) == 'per ' then
-- Similarly want "per U.S. gallon", not "U.S. per gallon" (but in practice this is unlikely to be used).
pertext = 'per '
id = id:sub(5)
else
pertext = ''
end
-- Omit any "US"/"U.S."/"imp"/"imperial" from start of id since that will be inserted.
local removes = (i < 3) and { 'US ', 'US ', 'U.S. ', 'U.S. ' } or { 'imp ', 'imp ', 'imperial ' }
for _, prefix in ipairs(removes) do
local plen = #prefix
if id:sub(1, plen) == prefix then
id = id:sub(plen + 1)
break
end
end
before = pertext .. make_link(customary.link, customary[1]) .. ' '
end
id = before .. make_link(link, id, unit_table)
end
end
return multiplier .. id
end
local function make_id(parms, which, unit_table)
-- Return id, f where
-- id = unit name or symbol, possibly modified
-- f = true if id is a name, or false if id is a symbol
-- using the value for index 'which', and for 'in' or 'out' (unit_table.inout).
-- Result is '' if no symbol/name is to be used.
-- In addition, set unit_table.sep = ' ' or ' ' or ''
-- (the separator that caller will normally insert before the id).
if parms.opt_values then
unit_table.sep = ''
return ''
end
local inout = unit_table.inout
local info = unit_table.valinfo[which]
local abbr_org = parms.abbr_org
local adjectival = parms.opt_adjectival
local lk = parms.lk
local want_link = (lk == 'on' or lk == inout)
local usename = unit_table.usename
local singular = info.singular
local want_name
if usename then
want_name = true
else
if abbr_org == nil then
if parms.wantname then
want_name = true
end
if unit_table.usesymbol then
want_name = false
end
end
if want_name == nil then
local abbr = parms.abbr
if abbr == 'on' or abbr == inout or (abbr == 'mos' and inout == 'out') then
want_name = false
else
want_name = true
end
end
end
local key
if want_name then
if lk == nil and unit_table.builtin == 'hand' then
want_link = true
end
if parms.opt_use_nbsp then
unit_table.sep = ' '
else
unit_table.sep = ' '
end
if parms.opt_singular then
local value
if inout == 'in' then
value = info.value
else
value = info.absvalue
end
if value then -- some unusual units do not always set value field
value = abs(value)
singular = (0 < value and value < 1.0001)
end
end
if unit_table.engscale then
-- engscale: so "|1|e3kg" gives "1 thousand kilograms" (plural)
singular = false
end
key = (adjectival or singular) and 'name1' or 'name2'
if parms.opt_sp_us then
key = key .. '_us'
end
else
if unit_table.builtin == 'hand' then
if parms.opt_hand_hh then
unit_table.symbol = 'hh' -- LATER: might want i18n applied to this
end
end
unit_table.sep = ' '
key = parms.opt_sp_us and 'sym_us' or 'symbol'
end
return linked_id(parms, unit_table, key, want_link, info.clean), want_name
end
local function decorate_value(parms, unit_table, which, number_word)
-- If needed, update unit_table so values will be shown with extra information.
-- For consistency with the old template (but different from fmtpower),
-- the style to display powers of 10 includes "display:none" to allow some
-- browsers to copy, for example, "10³" as "10^3", rather than as "103".
local info
local engscale = unit_table.engscale
local prefix = unit_table.vprefix
if engscale or prefix then
info = unit_table.valinfo[which]
if info.decorated then
return -- do not redecorate if repeating convert
end
info.decorated = true
if engscale then
local inout = unit_table.inout
local abbr = parms.abbr
if (abbr == 'on' or abbr == inout) and not parms.number_word then
info.show = info.show ..
'<span style="margin-left:0.2em">×<span style="margin-left:0.1em">' ..
from_en('10') ..
'</span></span><s style="display:none">^</s><sup>' ..
from_en(tostring(engscale.exponent)) .. '</sup>'
elseif number_word then
local number_id
local lk = parms.lk
if lk == 'on' or lk == inout then
number_id = make_link(engscale.link, engscale[1])
else
number_id = engscale[1]
end
-- WP:NUMERAL recommends " " in values like "12 million".
info.show = info.show .. (parms.opt_adjectival and '-' or ' ') .. number_id
end
end
if prefix then
info.show = prefix .. info.show
end
end
end
local function process_input(parms, in_current)
-- Processing required once per conversion.
-- Return block of text to represent input (value/unit).
if parms.opt_output_only or parms.opt_output_number_only or parms.opt_output_unit_only then
parms.joins = { '', '' }
return ''
end
local first_unit
local composite = in_current.composite -- nil or table of units
if composite then
first_unit = composite[1]
else
first_unit = in_current
end
local id1, want_name = make_id(parms, 1, first_unit)
local sep = first_unit.sep -- separator between value and unit, set by make_id
local preunit = parms.preunit1
if preunit then
sep = '' -- any separator is included in preunit
else
preunit = ''
end
if parms.opt_input_unit_only then
parms.joins = { '', '' }
if composite then
local parts = { id1 }
for i, unit in ipairs(composite) do
if i > 1 then
table.insert(parts, (make_id(parms, 1, unit)))
end
end
id1 = table.concat(parts, ' ')
end
if want_name and parms.opt_adjectival then
return preunit .. hyphenated(id1)
end
return preunit .. id1
end
if parms.opt_also_symbol and not composite and not parms.opt_flip then
local join1 = parms.joins[1]
if join1 == ' (' or join1 == ' [' then
parms.joins = { ' [' .. first_unit[parms.opt_sp_us and 'sym_us' or 'symbol'] .. ']' .. join1 , parms.joins[2] }
end
end
if in_current.builtin == 'mach' and first_unit.sep ~= '' then -- '' means omitsep with non-enwiki name
local prefix = id1 .. ' '
local range = parms.range
local valinfo = first_unit.valinfo
local result = prefix .. valinfo[1].show
if range then
-- For simplicity and because more not needed, handle one range item only.
local prefix2 = make_id(parms, 2, first_unit) .. ' '
result = range_text(range[1], want_name, parms, result, prefix2 .. valinfo[2].show, 'in', {spaced=true})
end
return preunit .. result
end
if composite then
-- Simplify: assume there is no range, and no decoration.
local mid = (not parms.opt_flip) and parms.mid or ''
local sep1 = ' '
local sep2 = ' '
if parms.opt_adjectival and want_name then
sep1 = '-'
sep2 = '-'
end
if omitsep and sep == '' then
-- Testing the id of the most significant unit should be sufficient.
sep1 = ''
sep2 = ''
end
local parts = { first_unit.valinfo[1].show .. sep1 .. id1 }
for i, unit in ipairs(composite) do
if i > 1 then
table.insert(parts, unit.valinfo[1].show .. sep1 .. (make_id(parms, 1, unit)))
end
end
return table.concat(parts, sep2) .. mid
end
local add_unit = (parms.abbr == 'mos') or
parms[parms.opt_flip and 'out_range_x' or 'in_range_x'] or
(not want_name and parms.abbr_range_x)
local range = parms.range
if range and not add_unit then
unlink(first_unit)
end
local id = range and make_id(parms, range.n + 1, first_unit) or id1
local extra, was_hyphenated = hyphenated_maybe(parms, want_name, sep, id, 'in')
if was_hyphenated then
add_unit = false
end
local result
local valinfo = first_unit.valinfo
if range then
for i = 0, range.n do
local number_word
if i == range.n then
add_unit = false
number_word = true
end
decorate_value(parms, first_unit, i+1, number_word)
local show = valinfo[i+1].show
if add_unit then
show = show .. first_unit.sep .. (i == 0 and id1 or make_id(parms, i+1, first_unit))
end
if i == 0 then
result = show
else
result = range_text(range[i], want_name, parms, result, show, 'in')
end
end
else
decorate_value(parms, first_unit, 1, true)
result = valinfo[1].show
end
return result .. preunit .. extra
end
local function process_one_output(parms, out_current)
-- Processing required for each output unit.
-- Return block of text to represent output (value/unit).
local inout = out_current.inout -- normally 'out' but can be 'in' for order=out
local id1, want_name = make_id(parms, 1, out_current)
local sep = out_current.sep -- set by make_id
local preunit = parms.preunit2
if preunit then
sep = '' -- any separator is included in preunit
else
preunit = ''
end
if parms.opt_output_unit_only then
if want_name and parms.opt_adjectival then
return preunit .. hyphenated(id1)
end
return preunit .. id1
end
if out_current.builtin == 'mach' and out_current.sep ~= '' then -- '' means omitsep with non-enwiki name
local prefix = id1 .. ' '
local range = parms.range
local valinfo = out_current.valinfo
local result = prefix .. valinfo[1].show
if range then
-- For simplicity and because more not needed, handle one range item only.
result = range_text(range[1], want_name, parms, result, prefix .. valinfo[2].show, inout, {spaced=true})
end
return preunit .. result
end
local add_unit = (parms[parms.opt_flip and 'in_range_x' or 'out_range_x'] or
(not want_name and parms.abbr_range_x)) and
not parms.opt_output_number_only
local range = parms.range
if range and not add_unit then
unlink(out_current)
end
local id = range and make_id(parms, range.n + 1, out_current) or id1
local extra, was_hyphenated = hyphenated_maybe(parms, want_name, sep, id, inout)
if was_hyphenated then
add_unit = false
end
local result
local valinfo = out_current.valinfo
if range then
for i = 0, range.n do
local number_word
if i == range.n then
add_unit = false
number_word = true
end
decorate_value(parms, out_current, i+1, number_word)
local show = valinfo[i+1].show
if add_unit then
show = show .. out_current.sep .. (i == 0 and id1 or make_id(parms, i+1, out_current))
end
if i == 0 then
result = show
else
result = range_text(range[i], want_name, parms, result, show, inout)
end
end
else
decorate_value(parms, out_current, 1, true)
result = valinfo[1].show
end
if parms.opt_output_number_only then
return result
end
return result .. preunit .. extra
end
local function make_output_single(parms, in_unit_table, out_unit_table)
-- Return true, item where item = wikitext of the conversion result
-- for a single output (which is not a combination or a multiple);
-- or return false, t where t is an error message table.
if parms.opt_order_out and in_unit_table.unitcode == out_unit_table.unitcode then
out_unit_table.valinfo = in_unit_table.valinfo
else
out_unit_table.valinfo = collection()
for _, v in ipairs(in_unit_table.valinfo) do
local success, info = cvtround(parms, v, in_unit_table, out_unit_table)
if not success then return false, info end
out_unit_table.valinfo:add(info)
end
end
return true, process_one_output(parms, out_unit_table)
end
local function make_output_multiple(parms, in_unit_table, out_unit_table)
-- Return true, item where item = wikitext of the conversion result
-- for an output which is a multiple (like 'ftin');
-- or return false, t where t is an error message table.
local inout = out_unit_table.inout -- normally 'out' but can be 'in' for order=out
local multiple = out_unit_table.multiple -- table of scaling factors (will not be nil)
local combos = out_unit_table.combination -- table of unit tables (will not be nil)
local abbr = parms.abbr
local abbr_org = parms.abbr_org
local disp = parms.disp
local want_name = (abbr_org == nil and (disp == 'or' or disp == 'slash')) or
not (abbr == 'on' or abbr == inout or abbr == 'mos')
local want_link = (parms.lk == 'on' or parms.lk == inout)
local mid = parms.opt_flip and parms.mid or ''
local sep1 = ' '
local sep2 = ' '
if parms.opt_adjectival and want_name then
sep1 = '-'
sep2 = '-'
end
local do_spell = parms.opt_spell_out
parms.opt_spell_out = nil -- so the call to cvtround does not spell the value
local function make_result(info, isfirst)
local fmt, outvalue, sign
local results = {}
for i = 1, #combos do
local tfrac, thisvalue, strforce
local out_current = combos[i]
out_current.inout = inout
local scale = multiple[i]
if i == 1 then -- least significant unit ('in' from 'ftin')
local decimals
out_current.frac = out_unit_table.frac
local success, outinfo = cvtround(parms, info, in_unit_table, out_current)
if not success then return false, outinfo end
if isfirst then
out_unit_table.valinfo = { outinfo } -- in case output value of first least significant unit is needed
end
sign = outinfo.sign
tfrac = outinfo.fraction_table
if outinfo.is_scientific then
strforce = outinfo.show
decimals = ''
elseif tfrac then
decimals = ''
else
local show = outinfo.show -- number as a string in local language
local p1, p2 = show:find(numdot, 1, true)
decimals = p1 and show:sub(p2 + 1) or '' -- text after numdot, if any
end
fmt = '%.' .. ulen(decimals) .. 'f' -- to reproduce precision
if decimals == '' then
if tfrac then
outvalue = floor(outinfo.raw_absvalue) -- integer part only; fraction added later
else
outvalue = floor(outinfo.raw_absvalue + 0.5) -- keep all integer digits of least significant unit
end
else
outvalue = outinfo.absvalue
end
end
if scale then
outvalue, thisvalue = divide(outvalue, scale)
else
thisvalue = outvalue
end
local id
if want_name then
if varname then
local clean
if strforce or tfrac then
clean = '.1' -- dummy value to force name for floating point
else
clean = format(fmt, thisvalue)
end
id = variable_name(clean, out_current)
else
local key = 'name2'
if parms.opt_adjectival then
key = 'name1'
elseif tfrac then
if thisvalue == 0 then
key = 'name1'
end
elseif parms.opt_singular then
if 0 < thisvalue and thisvalue < 1.0001 then
key = 'name1'
end
else
if thisvalue == 1 then
key = 'name1'
end
end
id = out_current[key]
end
else
id = out_current['symbol']
end
if i == 1 and omit_separator(id) then
-- Testing the id of the least significant unit should be sufficient.
sep1 = ''
sep2 = ''
end
if want_link then
local link = out_current.link
if link then
id = make_link(link, id, out_current)
end
end
local strval
local spell_inout = (i == #combos or outvalue == 0) and inout or '' -- trick so the last value processed (first displayed) has uppercase, if requested
if strforce and outvalue == 0 then
sign = '' -- any sign is in strforce
strval = strforce -- show small values in scientific notation; will only use least significant unit
elseif tfrac then
local wholestr = (thisvalue > 0) and tostring(thisvalue) or nil
strval = format_fraction(parms, spell_inout, false, wholestr, tfrac.numstr, tfrac.denstr, do_spell)
else
strval = (thisvalue == 0) and from_en('0') or with_separator(parms, format(fmt, thisvalue))
if do_spell then
strval = spell_number(parms, spell_inout, strval) or strval
end
end
table.insert(results, strval .. sep1 .. id)
if outvalue == 0 then
break
end
fmt = '%.0f' -- only least significant unit can have a non-integral value
end
local reversed, count = {}, #results
for i = 1, count do
reversed[i] = results[count + 1 - i]
end
return true, sign .. table.concat(reversed, sep2)
end
local valinfo = in_unit_table.valinfo
local success, result = make_result(valinfo[1], true)
if not success then return false, result end
local range = parms.range
if range then
for i = 1, range.n do
local success, result2 = make_result(valinfo[i+1])
if not success then return false, result2 end
result = range_text(range[i], want_name, parms, result, result2, inout, {spaced=true})
end
end
return true, result .. mid
end
local function process(parms, in_unit_table, out_unit_table)
-- Return true, s, outunit where s = final wikitext result,
-- or return false, t where t is an error message table.
linked_pages = {}
local success, bad_output
local bad_input_mcode = in_unit_table.bad_mcode -- nil if input unit is a valid convert unit
local out_unit = parms.out_unit
if out_unit == nil or out_unit == '' or type(out_unit) == 'function' then
if bad_input_mcode or parms.opt_input_unit_only then
bad_output = ''
else
local getdef = type(out_unit) == 'function' and out_unit or get_default
success, out_unit = getdef(in_unit_table.valinfo[1].value, in_unit_table)
parms.out_unit = out_unit
if not success then
bad_output = out_unit
end
end
end
if not bad_output and not out_unit_table then
success, out_unit_table = lookup(parms, out_unit, 'any_combination')
if success then
local mismatch = check_mismatch(in_unit_table, out_unit_table)
if mismatch then
bad_output = mismatch
end
else
bad_output = out_unit_table
end
end
local lhs, rhs
local flipped = parms.opt_flip and not bad_input_mcode
if bad_output then
rhs = (bad_output == '') and '' or message(parms, bad_output)
elseif parms.opt_input_unit_only then
rhs = ''
else
local combos -- nil (for 'ft' or 'ftin'), or table of unit tables (for 'm ft')
if not out_unit_table.multiple then -- nil/false ('ft' or 'm ft'), or table of factors ('ftin')
combos = out_unit_table.combination
end
local frac = parms.frac -- nil or denominator of fraction for output values
if frac then
-- Apply fraction to the unit (if only one), or to non-SI units (if a combination),
-- except that if a precision is also specified, the fraction only applies to
-- the hand unit; that allows the following result:
-- {{convert|156|cm|in hand|1|frac=2}} → 156 centimetres (61.4 in; 15.1½ hands)
-- However, the following is handled elsewhere as a special case:
-- {{convert|156|cm|hand in|1|frac=2}} → 156 centimetres (15.1½ hands; 61½ in)
if combos then
local precision = parms.precision
for _, unit in ipairs(combos) do
if unit.builtin == 'hand' or (not precision and not unit.prefixes) then
unit.frac = frac
end
end
else
out_unit_table.frac = frac
end
end
local outputs = {}
local imax = combos and #combos or 1 -- 1 (single unit) or number of unit tables
if imax == 1 then
parms.opt_order_out = nil -- only useful with an output combination
end
if not flipped and not parms.opt_order_out then
-- Process left side first so any duplicate links (from lk=on) are suppressed
-- on right. Example: {{convert|28|e9pc|e9ly|abbr=off|lk=on}}
lhs = process_input(parms, in_unit_table)
end
for i = 1, imax do
local success, item
local out_current = combos and combos[i] or out_unit_table
out_current.inout = 'out'
if i == 1 then
if imax > 1 and out_current.builtin == 'hand' then
out_current.out_next = combos[2] -- built-in hand can influence next unit in a combination
end
if parms.opt_order_out then
out_current.inout = 'in'
end
end
if out_current.multiple then
success, item = make_output_multiple(parms, in_unit_table, out_current)
else
success, item = make_output_single(parms, in_unit_table, out_current)
end
if not success then return false, item end
outputs[i] = item
end
if parms.opt_order_out then
lhs = outputs[1]
table.remove(outputs, 1)
end
local sep = parms.table_joins and parms.table_joins[2] or parms.join_between
rhs = table.concat(outputs, sep)
end
if flipped or not lhs then
local input = process_input(parms, in_unit_table)
if flipped then
lhs = rhs
rhs = input
else
lhs = input
end
end
if parms.join_before then
lhs = parms.join_before .. lhs
end
local wikitext
if bad_input_mcode then
if bad_input_mcode == '' then
wikitext = lhs
else
wikitext = lhs .. message(parms, bad_input_mcode)
end
elseif parms.table_joins then
wikitext = parms.table_joins[1] .. lhs .. parms.table_joins[2] .. rhs
else
wikitext = lhs .. parms.joins[1] .. rhs .. parms.joins[2]
end
if parms.warnings and not bad_input_mcode then
wikitext = wikitext .. parms.warnings
end
return true, get_styles(parms) .. wikitext, out_unit_table
end
local function main_convert(frame)
-- Do convert, and if needed, do it again with higher default precision.
local parms = { frame = frame } -- will hold template arguments, after translation
set_config(frame.args)
local success, result = get_parms(parms, frame:getParent().args)
if success then
if type(result) ~= 'table' then
return tostring(result)
end
local in_unit_table = result
local out_unit_table
for _ = 1, 2 do -- use counter so cannot get stuck repeating convert
success, result, out_unit_table = process(parms, in_unit_table, out_unit_table)
if success and parms.do_convert_again then
parms.do_convert_again = false
else
break
end
end
end
-- If input=x gives a problem, the result should be just the user input
-- (if x is a property like P123 it has been replaced with '').
-- An unknown input unit would display the input and an error message
-- with success == true at this point.
-- Also, can have success == false with a message that outputs an empty string.
if parms.input_text then
if success and not parms.have_problem then
return result
end
local cat
if parms.tracking then
-- Add a tracking category using the given text as the category sort key.
-- There is currently only one type of tracking, but in principle multiple
-- items could be tracked, using different sort keys for convenience.
cat = wanted_category('tracking', parms.tracking)
end
return parms.input_text .. (cat or '')
end
return success and result or message(parms, result)
end
local function _unit(unitcode, options)
-- Helper function for Module:Val to look up a unit.
-- Parameter unitcode must be a string to identify the wanted unit.
-- Parameter options must be nil or a table with optional fields:
-- value = number (for sort key; default value is 1)
-- scaled_top = nil for a normal unit, or a number for a unit which is
-- the denominator of a per unit (for sort key)
-- si = { 'symbol', 'link' }
-- (a table with two strings) to make an SI unit
-- that will be used for the look up
-- link = true if result should be [[linked]]
-- sort = 'on' or 'debug' if result should include a sort key in a
-- span element ('debug' makes the key visible)
-- name = true for the name of the unit instead of the symbol
-- us = true for the US spelling of the unit, if any
-- Return nil if unitcode is not a non-empty string.
-- Otherwise return a table with fields:
-- text = requested symbol or name of unit, optionally linked
-- scaled_value = input value adjusted by unit scale; used for sort key
-- sortspan = span element with sort key like that provided by {{ntsh}},
-- calculated from the result of converting value
-- to a base unit with scale 1.
-- unknown = true if the unitcode was not known
unitcode = strip(unitcode)
if unitcode == nil or unitcode == '' then
return nil
end
set_config({})
linked_pages = {}
options = options or {}
local parms = {
abbr = options.name and 'off' or 'on',
lk = options.link and 'on' or nil,
opt_sp_us = options.us and true or nil,
opt_ignore_error = true, -- do not add pages using this function to 'what links here' for Module:Convert/extra
opt_sortable_on = options.sort == 'on' or options.sort == 'debug',
opt_sortable_debug = options.sort == 'debug',
}
if options.si then
-- Make a dummy table of units (just one unit) for lookup to use.
-- This makes lookup recognize any SI prefix in the unitcode.
local symbol = options.si[1] or '?'
parms.unittable = { [symbol] = {
_name1 = symbol,
_name2 = symbol,
_symbol = symbol,
utype = symbol,
scale = symbol == 'g' and 0.001 or 1,
prefixes = 1,
default = symbol,
link = options.si[2],
}}
end
local success, unit_table = lookup(parms, unitcode, 'no_combination')
if not success then
unit_table = setmetatable({
symbol = unitcode, name2 = unitcode, utype = unitcode,
scale = 1, default = '', defkey = '', linkey = '' }, unit_mt)
end
local value = tonumber(options.value) or 1
local clean = tostring(abs(value))
local info = {
value = value,
altvalue = value,
singular = (clean == '1'),
clean = clean,
show = clean,
}
unit_table.inout = 'in'
unit_table.valinfo = { info }
local sortspan, scaled_value
if options.sort then
sortspan, scaled_value = make_table_or_sort(parms, value, info, unit_table, options.scaled_top)
end
return {
text = make_id(parms, 1, unit_table),
sortspan = sortspan,
scaled_value = scaled_value,
unknown = not success and true or nil,
}
end
return { convert = main_convert, _unit = _unit }
cac541bea61c5fbbcb0a2768343935e97587b60a
Module:Convert/data
828
89
182
181
2023-10-01T08:32:38Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- Conversion data used by [[Module:Convert]] which uses mw.loadData() for
-- read-only access to this module so that it is loaded only once per page.
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
--
-- These data tables follow:
-- all_units all properties for a unit, including default output
-- default_exceptions exceptions for default output ('kg' and 'g' have different defaults)
-- link_exceptions exceptions for links ('kg' and 'g' have different links)
--
-- These tables are generated by a script which reads the wikitext of a page that
-- documents the required properties of each unit; see [[:en:Module:Convert/doc]].
---------------------------------------------------------------------------
-- Do not change the data in this table because it is created by running --
-- a script that reads the wikitext from a wiki page (see note above). --
---------------------------------------------------------------------------
local all_units = {
["Gy"] = {
_name1 = "gray",
_symbol = "Gy",
utype = "absorbed radiation dose",
scale = 1,
prefixes = 1,
default = "rad",
link = "Gray (unit)",
},
["rad"] = {
_name1 = "rad",
_symbol = "rad",
utype = "absorbed radiation dose",
scale = 0.01,
prefixes = 1,
default = "Gy",
link = "Rad (unit)",
},
["cm/s2"] = {
name1 = "centimetre per second squared",
name1_us = "centimeter per second squared",
name2 = "centimetres per second squared",
name2_us = "centimeters per second squared",
symbol = "cm/s<sup>2</sup>",
utype = "acceleration",
scale = 0.01,
default = "ft/s2",
link = "Gal (unit)",
},
["ft/s2"] = {
name1 = "foot per second squared",
name2 = "feet per second squared",
symbol = "ft/s<sup>2</sup>",
utype = "acceleration",
scale = 0.3048,
default = "m/s2",
},
["g0"] = {
name1 = "standard gravity",
name2 = "standard gravities",
symbol = "''g''<sub>0</sub>",
utype = "acceleration",
scale = 9.80665,
default = "m/s2",
},
["g-force"] = {
name2 = "''g''",
symbol = "''g''",
utype = "acceleration",
scale = 9.80665,
default = "m/s2",
link = "g-force",
},
["km/hs"] = {
name1 = "kilometre per hour per second",
name1_us = "kilometer per hour per second",
name2 = "kilometres per hour per second",
name2_us = "kilometers per hour per second",
symbol = "km/(h⋅s)",
utype = "acceleration",
scale = 0.27777777777777779,
default = "mph/s",
link = "Acceleration",
},
["km/s2"] = {
name1 = "kilometre per second squared",
name1_us = "kilometer per second squared",
name2 = "kilometres per second squared",
name2_us = "kilometers per second squared",
symbol = "km/s<sup>2</sup>",
utype = "acceleration",
scale = 1000,
default = "mph/s",
link = "Acceleration",
},
["m/s2"] = {
name1 = "metre per second squared",
name1_us = "meter per second squared",
name2 = "metres per second squared",
name2_us = "meters per second squared",
symbol = "m/s<sup>2</sup>",
utype = "acceleration",
scale = 1,
default = "ft/s2",
},
["mph/s"] = {
name1 = "mile per hour per second",
name2 = "miles per hour per second",
symbol = "mph/s",
utype = "acceleration",
scale = 0.44704,
default = "km/hs",
link = "Acceleration",
},
["km/h/s"] = {
target = "km/hs",
},
["standard gravity"] = {
target = "g0",
},
["1000sqft"] = {
name1 = "thousand square feet",
name2 = "thousand square feet",
symbol = "1000 sq ft",
utype = "area",
scale = 92.90304,
default = "m2",
link = "Square foot",
},
["a"] = {
_name1 = "are",
_symbol = "a",
utype = "area",
scale = 100,
prefixes = 1,
default = "sqft",
link = "Hectare#Are",
},
["acre"] = {
symbol = "acre",
usename = 1,
utype = "area",
scale = 4046.8564224,
default = "ha",
subdivs = { ["rood"] = { 4, default = "ha" }, ["sqperch"] = { 160, default = "ha" } },
},
["acre-sing"] = {
target = "acre",
},
["arpent"] = {
symbol = "arpent",
usename = 1,
utype = "area",
scale = 3418.89,
default = "ha",
},
["cda"] = {
name1 = "cuerda",
symbol = "cda",
utype = "area",
scale = 3930.395625,
default = "ha acre",
},
["daa"] = {
name1 = "decare",
symbol = "daa",
utype = "area",
scale = 1000,
default = "km2 sqmi",
},
["dunam"] = {
symbol = "dunam",
usename = 1,
utype = "area",
scale = 1000,
default = "km2 sqmi",
},
["dunum"] = {
symbol = "dunum",
usename = 1,
utype = "area",
scale = 1000,
default = "km2 sqmi",
link = "Dunam",
},
["ha"] = {
name1 = "hectare",
symbol = "ha",
utype = "area",
scale = 10000,
default = "acre",
},
["hectare"] = {
name1 = "hectare",
symbol = "ha",
usename = 1,
utype = "area",
scale = 10000,
default = "acre",
},
["Irish acre"] = {
name1 = "Irish acre",
symbol = "Irish acres",
utype = "area",
scale = 6555.2385024,
default = "ha",
link = "Acre (Irish)",
},
["m2"] = {
_name1 = "square metre",
_name1_us= "square meter",
_symbol = "m<sup>2</sup>",
prefix_position= 8,
utype = "area",
scale = 1,
prefixes = 2,
default = "sqft",
link = "Square metre",
},
["pondemaat"] = {
name1 = "pondemaat",
name2 = "pondemaat",
symbol = "pond",
utype = "area",
scale = 3674.363358816,
default = "m2",
link = ":nl:pondemaat",
},
["pyeong"] = {
name2 = "pyeong",
symbol = "pyeong",
usename = 1,
utype = "area",
scale = 3.3057851239669422,
default = "m2",
},
["rai"] = {
name2 = "rai",
symbol = "rai",
utype = "area",
scale = 1600,
default = "m2",
link = "Rai (unit)",
},
["rood"] = {
symbol = "rood",
usename = 1,
utype = "area",
scale = 1011.7141056,
default = "sqft m2",
subdivs = { ["sqperch"] = { 40, default = "m2" } },
link = "Rood (unit)",
},
["sqfoot"] = {
name1 = "square foot",
name2 = "square foot",
symbol = "sq ft",
utype = "area",
scale = 0.09290304,
default = "m2",
},
["sqft"] = {
name1 = "square foot",
name2 = "square feet",
symbol = "sq ft",
utype = "area",
scale = 0.09290304,
default = "m2",
},
["sqin"] = {
name1 = "square inch",
name2 = "square inches",
symbol = "sq in",
utype = "area",
scale = 0.00064516,
default = "cm2",
},
["sqmi"] = {
name1 = "square mile",
symbol = "sq mi",
utype = "area",
scale = 2589988.110336,
default = "km2",
},
["sqnmi"] = {
name1 = "square nautical mile",
symbol = "sq nmi",
utype = "area",
scale = 3429904,
default = "km2 sqmi",
link = "Nautical mile",
},
["sqperch"] = {
name2 = "perches",
symbol = "perch",
usename = 1,
utype = "area",
scale = 25.29285264,
default = "m2",
link = "Rod (unit)#Area and volume",
},
["sqverst"] = {
symbol = "square verst",
usename = 1,
utype = "area",
scale = 1138062.24,
default = "km2 sqmi",
link = "Verst",
},
["sqyd"] = {
name1 = "square yard",
symbol = "sq yd",
utype = "area",
scale = 0.83612736,
default = "m2",
},
["tsubo"] = {
name2 = "tsubo",
symbol = "tsubo",
usename = 1,
utype = "area",
scale = 3.3057851239669422,
default = "m2",
link = "Japanese units of measurement#Area",
},
["acres"] = {
target = "acre",
},
["are"] = {
target = "a",
},
["decare"] = {
target = "daa",
},
["foot2"] = {
target = "sqfoot",
},
["ft2"] = {
target = "sqft",
},
["in2"] = {
target = "sqin",
symbol = "in<sup>2</sup>",
},
["km²"] = {
target = "km2",
},
["mi2"] = {
target = "sqmi",
},
["million acre"] = {
target = "e6acre",
},
["million acres"] = {
target = "e6acre",
},
["million hectares"] = {
target = "e6ha",
},
["m²"] = {
target = "m2",
},
["nmi2"] = {
target = "sqnmi",
},
["pond"] = {
target = "pondemaat",
},
["sq arp"] = {
target = "arpent",
},
["sqkm"] = {
target = "km2",
},
["sqm"] = {
target = "m2",
},
["square verst"] = {
target = "sqverst",
},
["verst2"] = {
target = "sqverst",
},
["yd2"] = {
target = "sqyd",
},
["m2/ha"] = {
name1 = "square metre per hectare",
name1_us = "square meter per hectare",
name2 = "square metres per hectare",
name2_us = "square meters per hectare",
symbol = "m<sup>2</sup>/ha",
utype = "area per unit area",
scale = 0.0001,
default = "sqft/acre",
link = "Basal area",
},
["sqft/acre"] = {
name1 = "square foot per acre",
name2 = "square feet per acre",
symbol = "sq ft/acre",
utype = "area per unit area",
scale = 2.295684113865932e-5,
default = "m2/ha",
link = "Basal area",
},
["cent"] = {
name1 = "cent",
symbol = "¢",
utype = "cent",
scale = 1,
default = "cent",
link = "Cent (currency)",
},
["¢"] = {
target = "cent",
},
["A.h"] = {
name1 = "ampere hour",
symbol = "A⋅h",
utype = "charge",
scale = 3600,
default = "coulomb",
},
["coulomb"] = {
_name1 = "coulomb",
_symbol = "C",
utype = "charge",
scale = 1,
prefixes = 1,
default = "e",
link = "Coulomb",
},
["e"] = {
name1 = "elementary charge",
symbol = "''e''",
utype = "charge",
scale = 1.602176487e-19,
default = "coulomb",
},
["g-mol"] = {
name1 = "gram-mole",
symbol = "g‑mol",
utype = "chemical amount",
scale = 1,
default = "lbmol",
link = "Mole (unit)",
},
["gmol"] = {
name1 = "gram-mole",
symbol = "gmol",
utype = "chemical amount",
scale = 1,
default = "lbmol",
link = "Mole (unit)",
},
["kmol"] = {
name1 = "kilomole",
symbol = "kmol",
utype = "chemical amount",
scale = 1000,
default = "lbmol",
link = "Mole (unit)",
},
["lb-mol"] = {
name1 = "pound-mole",
symbol = "lb‑mol",
utype = "chemical amount",
scale = 453.59237,
default = "mol",
},
["lbmol"] = {
name1 = "pound-mole",
symbol = "lbmol",
utype = "chemical amount",
scale = 453.59237,
default = "mol",
},
["mol"] = {
name1 = "mole",
symbol = "mol",
utype = "chemical amount",
scale = 1,
default = "lbmol",
link = "Mole (unit)",
},
["kgCO2/L"] = {
name1 = "kilogram per litre",
name1_us = "kilogram per liter",
name2 = "kilograms per litre",
name2_us = "kilograms per liter",
symbol = "kg(CO<sub>2</sub>)/L",
utype = "co2 per unit volume",
scale = 1000,
default = "lbCO2/USgal",
link = "Exhaust gas",
},
["lbCO2/USgal"] = {
name1 = "pound per US gallon",
name2 = "pounds per US gallon",
symbol = "lbCO2/US gal",
utype = "co2 per unit volume",
scale = 119.82642731689663,
default = "kgCO2/L",
link = "Exhaust gas",
},
["oz/lb"] = {
per = { "oz", "lb" },
utype = "concentration",
default = "mg/kg",
},
["mg/kg"] = {
per = { "mg", "kg" },
utype = "concentration",
default = "oz/lb",
},
["g/dm3"] = {
name1 = "gram per cubic decimetre",
name1_us = "gram per cubic decimeter",
name2 = "grams per cubic decimetre",
name2_us = "grams per cubic decimeter",
symbol = "g/dm<sup>3</sup>",
utype = "density",
scale = 1,
default = "kg/m3",
link = "Density",
},
["g/L"] = {
name1 = "gram per litre",
name1_us = "gram per liter",
name2 = "grams per litre",
name2_us = "grams per liter",
symbol = "g/L",
utype = "density",
scale = 1,
default = "lb/cuin",
link = "Density",
},
["g/mL"] = {
name1 = "gram per millilitre",
name1_us = "gram per milliliter",
name2 = "grams per millilitre",
name2_us = "grams per milliliter",
symbol = "g/mL",
utype = "density",
scale = 1000,
default = "lb/cuin",
link = "Density",
},
["g/ml"] = {
name1 = "gram per millilitre",
name1_us = "gram per milliliter",
name2 = "grams per millilitre",
name2_us = "grams per milliliter",
symbol = "g/ml",
utype = "density",
scale = 1000,
default = "lb/cuin",
link = "Density",
},
["kg/dm3"] = {
name1 = "kilogram per cubic decimetre",
name1_us = "kilogram per cubic decimeter",
name2 = "kilograms per cubic decimetre",
name2_us = "kilograms per cubic decimeter",
symbol = "kg/dm<sup>3</sup>",
utype = "density",
scale = 1000,
default = "lb/cuft",
link = "Density",
},
["kg/L"] = {
name1 = "kilogram per litre",
name1_us = "kilogram per liter",
name2 = "kilograms per litre",
name2_us = "kilograms per liter",
symbol = "kg/L",
utype = "density",
scale = 1000,
default = "lb/USgal",
link = "Density",
},
["kg/l"] = {
name1 = "kilogram per litre",
name1_us = "kilogram per liter",
name2 = "kilograms per litre",
name2_us = "kilograms per liter",
symbol = "kg/l",
utype = "density",
scale = 1000,
default = "lb/USgal",
link = "Density",
},
["kg/m3"] = {
name1 = "kilogram per cubic metre",
name1_us = "kilogram per cubic meter",
name2 = "kilograms per cubic metre",
name2_us = "kilograms per cubic meter",
symbol = "kg/m<sup>3</sup>",
utype = "density",
scale = 1,
default = "lb/cuyd",
link = "Density",
},
["lb/cuft"] = {
name1 = "pound per cubic foot",
name2 = "pounds per cubic foot",
symbol = "lb/cu ft",
utype = "density",
scale = 16.018463373960142,
default = "g/cm3",
link = "Density",
},
["lb/cuin"] = {
name1 = "pound per cubic inch",
name2 = "pounds per cubic inch",
symbol = "lb/cu in",
utype = "density",
scale = 27679.904710203122,
default = "g/cm3",
link = "Density",
},
["lb/cuyd"] = {
name1 = "pound per cubic yard",
name2 = "pounds per cubic yard",
symbol = "lb/cu yd",
utype = "density",
scale = 0.5932764212577829,
default = "kg/m3",
link = "Density",
},
["lb/impgal"] = {
name1 = "pound per imperial gallon",
name2 = "pounds per imperial gallon",
symbol = "lb/imp gal",
utype = "density",
scale = 99.776372663101697,
default = "kg/L",
link = "Density",
},
["lb/in3"] = {
name1 = "pound per cubic inch",
name2 = "pounds per cubic inch",
symbol = "lb/cu in",
utype = "density",
scale = 27679.904710203122,
default = "g/cm3",
link = "Density",
},
["lb/U.S.gal"] = {
name1 = "pound per U.S. gallon",
name2 = "pounds per U.S. gallon",
symbol = "lb/U.S. gal",
utype = "density",
scale = 119.82642731689663,
default = "kg/L",
link = "Density",
},
["lb/USbu"] = {
name1 = "pound per US bushel",
name2 = "pounds per US bushel",
symbol = "lb/US bu",
utype = "density",
scale = 12.871859780974471,
default = "kg/m3",
link = "Bushel",
},
["lb/USgal"] = {
name1 = "pound per US gallon",
name2 = "pounds per US gallon",
symbol = "lb/US gal",
utype = "density",
scale = 119.82642731689663,
default = "kg/L",
link = "Density",
},
["lbm/cuin"] = {
name1 = "pound mass per cubic inch",
name2 = "pounds mass per cubic inch",
symbol = "lbm/cu in",
utype = "density",
scale = 27679.904710203122,
default = "g/cm3",
link = "Density",
},
["mg/L"] = {
name1 = "milligram per litre",
name1_us = "milligram per liter",
name2 = "milligrams per litre",
name2_us = "milligrams per liter",
symbol = "mg/L",
utype = "density",
scale = 0.001,
default = "lb/cuin",
link = "Density",
},
["oz/cuin"] = {
name1 = "ounce per cubic inch",
name2 = "ounces per cubic inch",
symbol = "oz/cu in",
utype = "density",
scale = 1729.9940443876951,
default = "g/cm3",
link = "Density",
},
["g/cm3"] = {
per = { "g", "cm3" },
utype = "density",
default = "lb/cuin",
},
["g/m3"] = {
per = { "g", "m3" },
utype = "density",
default = "lb/cuyd",
link = "Density",
},
["Mg/m3"] = {
per = { "Mg", "m3" },
utype = "density",
default = "lb/cuft",
},
["mg/l"] = {
per = { "mg", "ll" },
utype = "density",
default = "oz/cuin",
},
["μg/dL"] = {
per = { "μg", "dL" },
utype = "density",
default = "lb/cuin",
},
["μg/l"] = {
per = { "μg", "ll" },
utype = "density",
default = "oz/cuin",
},
["lb/ft3"] = {
target = "lb/cuft",
},
["lb/yd3"] = {
target = "lb/cuyd",
},
["lbm/in3"] = {
target = "lbm/cuin",
},
["mcg/dL"] = {
target = "μg/dL",
},
["oz/in3"] = {
target = "oz/cuin",
},
["ug/dL"] = {
target = "μg/dL",
},
["ug/l"] = {
target = "μg/l",
},
["B.O.T.U."] = {
name1 = "Board of Trade Unit",
symbol = "B.O.T.U.",
utype = "energy",
scale = 3600000,
default = "MJ",
link = "Kilowatt-hour",
},
["bboe"] = {
name1 = "barrel of oil equivalent",
name2 = "barrels of oil equivalent",
symbol = "bboe",
utype = "energy",
scale = 6117863200,
default = "GJ",
},
["BOE"] = {
name1 = "barrel of oil equivalent",
name2 = "barrels of oil equivalent",
symbol = "BOE",
utype = "energy",
scale = 6117863200,
default = "GJ",
},
["BTU"] = {
name1 = "British thermal unit",
symbol = "BTU",
utype = "energy",
scale = 1055.05585262,
default = "kJ",
},
["Btu"] = {
name1 = "British thermal unit",
symbol = "Btu",
utype = "energy",
scale = 1055.05585262,
default = "kJ",
},
["BTU-39F"] = {
name1 = "British thermal unit (39°F)",
name2 = "British thermal units (39°F)",
symbol = "BTU<sub>39°F</sub>",
utype = "energy",
scale = 1059.67,
default = "kJ",
link = "British thermal unit",
},
["Btu-39F"] = {
name1 = "British thermal unit (39°F)",
name2 = "British thermal units (39°F)",
symbol = "Btu<sub>39°F</sub>",
utype = "energy",
scale = 1059.67,
default = "kJ",
link = "British thermal unit",
},
["BTU-59F"] = {
name1 = "British thermal unit (59°F)",
name2 = "British thermal units (59°F)",
symbol = "BTU<sub>59°F</sub>",
utype = "energy",
scale = 1054.804,
default = "kJ",
link = "British thermal unit",
},
["Btu-59F"] = {
name1 = "British thermal unit (59°F)",
name2 = "British thermal units (59°F)",
symbol = "Btu<sub>59°F</sub>",
utype = "energy",
scale = 1054.804,
default = "kJ",
link = "British thermal unit",
},
["BTU-60F"] = {
name1 = "British thermal unit (60°F)",
name2 = "British thermal units (60°F)",
symbol = "BTU<sub>60°F</sub>",
utype = "energy",
scale = 1054.68,
default = "kJ",
link = "British thermal unit",
},
["Btu-60F"] = {
name1 = "British thermal unit (60°F)",
name2 = "British thermal units (60°F)",
symbol = "Btu<sub>60°F</sub>",
utype = "energy",
scale = 1054.68,
default = "kJ",
link = "British thermal unit",
},
["BTU-63F"] = {
name1 = "British thermal unit (63°F)",
name2 = "British thermal units (63°F)",
symbol = "BTU<sub>63°F</sub>",
utype = "energy",
scale = 1054.6,
default = "kJ",
link = "British thermal unit",
},
["Btu-63F"] = {
name1 = "British thermal unit (63°F)",
name2 = "British thermal units (63°F)",
symbol = "Btu<sub>63°F</sub>",
utype = "energy",
scale = 1054.6,
default = "kJ",
link = "British thermal unit",
},
["BTU-ISO"] = {
name1 = "British thermal unit (ISO)",
name2 = "British thermal units (ISO)",
symbol = "BTU<sub>ISO</sub>",
utype = "energy",
scale = 1055.056,
default = "kJ",
link = "British thermal unit",
},
["Btu-ISO"] = {
target = "BTU-ISO",
},
["BTU-IT"] = {
name1 = "British thermal unit (IT)",
name2 = "British thermal units (IT)",
symbol = "BTU<sub>IT</sub>",
utype = "energy",
scale = 1055.05585262,
default = "kJ",
link = "British thermal unit",
},
["Btu-IT"] = {
name1 = "British thermal unit (IT)",
name2 = "British thermal units (IT)",
symbol = "Btu<sub>IT</sub>",
utype = "energy",
scale = 1055.05585262,
default = "kJ",
link = "British thermal unit",
},
["BTU-mean"] = {
name1 = "British thermal unit (mean)",
name2 = "British thermal units (mean)",
symbol = "BTU<sub>mean</sub>",
utype = "energy",
scale = 1055.87,
default = "kJ",
link = "British thermal unit",
},
["Btu-mean"] = {
name1 = "British thermal unit (mean)",
name2 = "British thermal units (mean)",
symbol = "Btu<sub>mean</sub>",
utype = "energy",
scale = 1055.87,
default = "kJ",
link = "British thermal unit",
},
["BTU-th"] = {
name1 = "British thermal unit (thermochemical)",
name2 = "British thermal units (thermochemical)",
symbol = "BTU<sub>th</sub>",
utype = "energy",
scale = 1054.35026444,
default = "kJ",
link = "British thermal unit",
},
["Btu-th"] = {
name1 = "British thermal unit (thermochemical)",
name2 = "British thermal units (thermochemical)",
symbol = "Btu<sub>th</sub>",
utype = "energy",
scale = 1054.35026444,
default = "kJ",
link = "British thermal unit",
},
["Cal"] = {
name1 = "calorie",
symbol = "Cal",
utype = "energy",
scale = 4184,
default = "kJ",
},
["cal"] = {
name1 = "calorie",
symbol = "cal",
utype = "energy",
scale = 4.184,
default = "J",
},
["Cal-15"] = {
name1 = "Calorie (15°C)",
name2 = "Calories (15°C)",
symbol = "Cal<sub>15</sub>",
utype = "energy",
scale = 4185.8,
default = "kJ",
link = "Calorie",
},
["cal-15"] = {
name1 = "calorie (15°C)",
name2 = "calories (15°C)",
symbol = "cal<sub>15</sub>",
utype = "energy",
scale = 4.1858,
default = "J",
link = "Calorie",
},
["Cal-IT"] = {
name1 = "Calorie (International Steam Table)",
name2 = "Calories (International Steam Table)",
symbol = "Cal<sub>IT</sub>",
utype = "energy",
scale = 4186.8,
default = "kJ",
link = "Calorie",
},
["cal-IT"] = {
name1 = "calorie (International Steam Table)",
name2 = "calories (International Steam Table)",
symbol = "cal<sub>IT</sub>",
utype = "energy",
scale = 4.1868,
default = "J",
link = "Calorie",
},
["Cal-th"] = {
name1 = "Calorie (thermochemical)",
name2 = "Calories (thermochemical)",
symbol = "Cal<sub>th</sub>",
utype = "energy",
scale = 4184,
default = "kJ",
link = "Calorie",
},
["cal-th"] = {
name1 = "calorie (thermochemical)",
name2 = "calories (thermochemical)",
symbol = "cal<sub>th</sub>",
utype = "energy",
scale = 4.184,
default = "J",
link = "Calorie",
},
["CHU-IT"] = {
name1 = "Celsius heat unit (International Table)",
name2 = "Celsius heat units (International Table)",
symbol = "CHU<sub>IT</sub>",
utype = "energy",
scale = 1899.100534716,
default = "kJ",
link = "Conversion of units#Energy",
},
["cufootnaturalgas"] = {
name1 = "cubic foot of natural gas",
name2 = "cubic foot of natural gas",
symbol = "cuftnaturalgas",
usename = 1,
utype = "energy",
scale = 1055055.85262,
default = "MJ",
link = "Conversion of units#Energy",
},
["cuftnaturalgas"] = {
name1 = "cubic foot of natural gas",
name2 = "cubic feet of natural gas",
symbol = "cuftnaturalgas",
usename = 1,
utype = "energy",
scale = 1055055.85262,
default = "MJ",
link = "Conversion of units#Energy",
},
["Eh"] = {
name1 = "Hartree",
symbol = "''E''<sub>h</sub>",
utype = "energy",
scale = 4.35974417e-18,
default = "eV",
},
["erg"] = {
symbol = "erg",
utype = "energy",
scale = 0.0000001,
default = "μJ",
},
["eV"] = {
name1 = "electronvolt",
symbol = "eV",
utype = "energy",
scale = 1.602176487e-19,
default = "aJ",
},
["feV"] = {
name1 = "femtoelectronvolt",
symbol = "feV",
utype = "energy",
scale = 1.602176487e-34,
default = "yJ",
link = "Electronvolt",
},
["foe"] = {
symbol = "foe",
utype = "energy",
scale = 1e44,
default = "YJ",
link = "Foe (unit)",
},
["ftlb"] = {
name1 = "foot-pound",
symbol = "ft⋅lb",
utype = "energy",
alttype = "torque",
scale = 1.3558179483314004,
default = "J",
link = "Foot-pound (energy)",
},
["ftlb-f"] = {
name1 = "foot-pound force",
name2 = "foot-pounds force",
symbol = "ft⋅lb<sub>f</sub>",
utype = "energy",
alttype = "torque",
scale = 1.3558179483314004,
default = "J",
link = "Foot-pound (energy)",
},
["ftlbf"] = {
name1 = "foot-pound force",
name2 = "foot-pounds force",
symbol = "ft⋅lbf",
utype = "energy",
alttype = "torque",
scale = 1.3558179483314004,
default = "J",
link = "Foot-pound (energy)",
},
["ftpdl"] = {
name1 = "foot-poundal",
symbol = "ft⋅pdl",
utype = "energy",
scale = 0.0421401100938048,
default = "J",
},
["GeV"] = {
name1 = "gigaelectronvolt",
symbol = "GeV",
utype = "energy",
scale = 1.602176487e-10,
default = "nJ",
link = "Electronvolt",
},
["gTNT"] = {
name2 = "grams of TNT",
symbol = "gram of TNT",
usename = 1,
utype = "energy",
scale = 4184,
default = "kJ",
link = "TNT equivalent",
},
["Gtoe"] = {
name1 = "gigatonne of oil equivalent",
name2 = "gigatonnes of oil equivalent",
symbol = "Gtoe",
utype = "energy",
scale = 4.1868e19,
default = "EJ",
link = "Tonne of oil equivalent",
},
["GtonTNT"] = {
name2 = "gigatons of TNT",
symbol = "gigaton of TNT",
usename = 1,
utype = "energy",
scale = 4.184e18,
default = "EJ",
link = "TNT equivalent",
},
["GtTNT"] = {
name2 = "gigatonnes of TNT",
symbol = "gigatonne of TNT",
usename = 1,
utype = "energy",
scale = 4.184e18,
default = "EJ",
link = "TNT equivalent",
},
["GW.h"] = {
name1 = "gigawatt-hour",
symbol = "GW⋅h",
utype = "energy",
scale = 3.6e12,
default = "TJ",
link = "Kilowatt-hour",
},
["GWh"] = {
name1 = "gigawatt-hour",
symbol = "GWh",
utype = "energy",
scale = 3.6e12,
default = "TJ",
link = "Kilowatt-hour",
},
["hph"] = {
name1 = "horsepower-hour",
symbol = "hp⋅h",
utype = "energy",
scale = 2684519.537696172792,
default = "kWh",
link = "Horsepower",
},
["inlb"] = {
name1 = "inch-pound",
symbol = "in⋅lb",
utype = "energy",
alttype = "torque",
scale = 0.1129848290276167,
default = "mJ",
link = "Foot-pound (energy)",
},
["inlb-f"] = {
name1 = "inch-pound force",
name2 = "inch-pounds force",
symbol = "in⋅lb<sub>f</sub>",
utype = "energy",
alttype = "torque",
scale = 0.1129848290276167,
default = "mJ",
link = "Foot-pound (energy)",
},
["inlbf"] = {
name1 = "inch-pound force",
name2 = "inch-pounds force",
symbol = "in⋅lbf",
utype = "energy",
alttype = "torque",
scale = 0.1129848290276167,
default = "mJ",
link = "Foot-pound (energy)",
},
["inoz-f"] = {
name1 = "inch-ounce force",
name2 = "inch-ounces force",
symbol = "in⋅oz<sub>f</sub>",
utype = "energy",
alttype = "torque",
scale = 0.00706155181422604375,
default = "mJ",
link = "Foot-pound (energy)",
},
["inozf"] = {
name1 = "inch-ounce force",
name2 = "inch-ounces force",
symbol = "in⋅ozf",
utype = "energy",
alttype = "torque",
scale = 0.00706155181422604375,
default = "mJ",
link = "Foot-pound (energy)",
},
["J"] = {
_name1 = "joule",
_symbol = "J",
utype = "energy",
scale = 1,
prefixes = 1,
default = "cal",
link = "Joule",
},
["kBOE"] = {
name1 = "kilo barrel of oil equivalent",
name2 = "kilo barrels of oil equivalent",
symbol = "kBOE",
utype = "energy",
scale = 6.1178632e12,
default = "TJ",
link = "Barrel of oil equivalent",
},
["kcal"] = {
name1 = "kilocalorie",
symbol = "kcal",
utype = "energy",
scale = 4184,
default = "kJ",
link = "Calorie",
},
["kcal-15"] = {
name1 = "kilocalorie (15°C)",
name2 = "kilocalories (15°C)",
symbol = "kcal<sub>15</sub>",
utype = "energy",
scale = 4185.8,
default = "kJ",
link = "Calorie",
},
["kcal-IT"] = {
name1 = "kilocalorie (International Steam Table)",
name2 = "kilocalories (International Steam Table)",
symbol = "kcal<sub>IT</sub>",
utype = "energy",
scale = 4186.8,
default = "kJ",
link = "Calorie",
},
["kcal-th"] = {
name1 = "kilocalorie (thermochemical)",
name2 = "kilocalories (thermochemical)",
symbol = "kcal<sub>th</sub>",
utype = "energy",
scale = 4184,
default = "kJ",
link = "Calorie",
},
["kerg"] = {
name1 = "kiloerg",
symbol = "kerg",
utype = "energy",
scale = 0.0001,
default = "mJ",
link = "Erg",
},
["keV"] = {
name1 = "kiloelectronvolt",
symbol = "keV",
utype = "energy",
scale = 1.602176487e-16,
default = "fJ",
link = "Electronvolt",
},
["kgTNT"] = {
name2 = "kilograms of TNT",
symbol = "kilogram of TNT",
usename = 1,
utype = "energy",
scale = 4184000,
default = "MJ",
link = "TNT equivalent",
},
["kt(TNT)"] = {
name1 = "kilotonne",
name1_us = "kiloton",
symbol = "kt",
utype = "energy",
scale = 4.184e12,
default = "TJ",
link = "TNT equivalent",
},
["ktoe"] = {
name1 = "kilotonne of oil equivalent",
name2 = "kilotonnes of oil equivalent",
symbol = "ktoe",
utype = "energy",
scale = 4.1868e13,
default = "TJ",
link = "Tonne of oil equivalent",
},
["ktonTNT"] = {
name1 = "kiloton of TNT",
name2 = "kilotons of TNT",
symbol = "kt",
utype = "energy",
scale = 4.184e12,
default = "TJ",
link = "TNT equivalent",
},
["ktTNT"] = {
name2 = "kilotonnes of TNT",
symbol = "kilotonne of TNT",
usename = 1,
utype = "energy",
scale = 4.184e12,
default = "TJ",
link = "TNT equivalent",
},
["kW.h"] = {
name1 = "kilowatt-hour",
symbol = "kW⋅h",
utype = "energy",
scale = 3600000,
default = "MJ",
},
["kWh"] = {
name1 = "kilowatt-hour",
symbol = "kWh",
utype = "energy",
scale = 3600000,
default = "MJ",
},
["Mcal"] = {
name1 = "megacalorie",
symbol = "Mcal",
utype = "energy",
scale = 4184000,
default = "MJ",
link = "Calorie",
},
["mcal"] = {
name1 = "millicalorie",
symbol = "mcal",
utype = "energy",
scale = 0.004184,
default = "mJ",
link = "Calorie",
},
["Mcal-15"] = {
name1 = "megacalorie (15°C)",
name2 = "megacalories (15°C)",
symbol = "Mcal<sub>15</sub>",
utype = "energy",
scale = 4185800,
default = "MJ",
link = "Calorie",
},
["mcal-15"] = {
name1 = "millicalorie (15°C)",
name2 = "millicalories (15°C)",
symbol = "mcal<sub>15</sub>",
utype = "energy",
scale = 0.0041858,
default = "mJ",
link = "Calorie",
},
["Mcal-IT"] = {
name1 = "megacalorie (International Steam Table)",
name2 = "megacalories (International Steam Table)",
symbol = "Mcal<sub>IT</sub>",
utype = "energy",
scale = 4186800,
default = "MJ",
link = "Calorie",
},
["mcal-IT"] = {
name1 = "millicalorie (International Steam Table)",
name2 = "millicalories (International Steam Table)",
symbol = "mcal<sub>IT</sub>",
utype = "energy",
scale = 0.0041868,
default = "mJ",
link = "Calorie",
},
["Mcal-th"] = {
name1 = "megacalorie (thermochemical)",
name2 = "megacalories (thermochemical)",
symbol = "Mcal<sub>th</sub>",
utype = "energy",
scale = 4184000,
default = "MJ",
link = "Calorie",
},
["mcal-th"] = {
name1 = "millicalorie (thermochemical)",
name2 = "millicalories (thermochemical)",
symbol = "mcal<sub>th</sub>",
utype = "energy",
scale = 0.004184,
default = "mJ",
link = "Calorie",
},
["Merg"] = {
name1 = "megaerg",
symbol = "Merg",
utype = "energy",
scale = 0.1,
default = "J",
link = "Erg",
},
["merg"] = {
name1 = "millierg",
symbol = "merg",
utype = "energy",
scale = 0.0000000001,
default = "μJ",
link = "Erg",
},
["MeV"] = {
name1 = "megaelectronvolt",
symbol = "MeV",
utype = "energy",
scale = 1.602176487e-13,
default = "pJ",
link = "Electronvolt",
},
["meV"] = {
name1 = "millielectronvolt",
symbol = "meV",
utype = "energy",
scale = 1.602176487e-22,
default = "zJ",
link = "Electronvolt",
},
["MMBtu"] = {
name1 = "million British thermal units",
name2 = "million British thermal units",
symbol = "MMBtu",
utype = "energy",
scale = 1055055852.62,
default = "GJ",
link = "British thermal unit",
},
["Mt(TNT)"] = {
name1 = "megatonne",
name1_us = "megaton",
symbol = "Mt",
utype = "energy",
scale = 4.184e15,
default = "PJ",
link = "TNT equivalent",
},
["Mtoe"] = {
name1 = "megatonne of oil equivalent",
name2 = "megatonnes of oil equivalent",
symbol = "Mtoe",
utype = "energy",
scale = 4.1868e16,
default = "PJ",
link = "Tonne of oil equivalent",
},
["MtonTNT"] = {
name1 = "megaton of TNT",
name2 = "megatons of TNT",
symbol = "Mt",
utype = "energy",
scale = 4.184e15,
default = "PJ",
link = "TNT equivalent",
},
["mtonTNT"] = {
name2 = "millitons of TNT",
symbol = "milliton of TNT",
usename = 1,
utype = "energy",
scale = 4184000,
default = "MJ",
link = "TNT equivalent",
},
["MtTNT"] = {
name2 = "megatonnes of TNT",
symbol = "megatonne of TNT",
usename = 1,
utype = "energy",
scale = 4.184e15,
default = "PJ",
link = "TNT equivalent",
},
["mtTNT"] = {
name2 = "millitonnes of TNT",
symbol = "millitonne of TNT",
usename = 1,
utype = "energy",
scale = 4184000,
default = "MJ",
link = "TNT equivalent",
},
["MW.h"] = {
name1 = "megawatt-hour",
symbol = "MW⋅h",
utype = "energy",
scale = 3600000000,
default = "GJ",
link = "Kilowatt-hour",
},
["mW.h"] = {
name1 = "milliwatt-hour",
symbol = "mW⋅h",
utype = "energy",
scale = 3.6,
default = "J",
link = "Kilowatt-hour",
},
["MWh"] = {
name1 = "megawatt-hour",
symbol = "MWh",
utype = "energy",
scale = 3600000000,
default = "GJ",
link = "Kilowatt-hour",
},
["mWh"] = {
name1 = "milliwatt-hour",
symbol = "mWh",
utype = "energy",
scale = 3.6,
default = "J",
link = "Kilowatt-hour",
},
["neV"] = {
name1 = "nanoelectronvolt",
symbol = "neV",
utype = "energy",
scale = 1.602176487e-28,
default = "yJ",
link = "Electronvolt",
},
["PeV"] = {
name1 = "petaelectronvolt",
symbol = "PeV",
utype = "energy",
scale = 0.0001602176487,
default = "mJ",
link = "Electronvolt",
},
["peV"] = {
name1 = "picoelectronvolt",
symbol = "peV",
utype = "energy",
scale = 1.602176487e-31,
default = "yJ",
link = "Electronvolt",
},
["PSh"] = {
name1 = "Pferdestärkenstunde",
symbol = "PSh",
utype = "energy",
scale = 2647795.5,
default = "kWh",
},
["quad"] = {
name1 = "quadrillion British thermal units",
name2 = "quadrillion British thermal units",
symbol = "quad",
utype = "energy",
scale = 1.054804e18,
default = "EJ",
link = "Quad (unit)",
},
["Ry"] = {
name1 = "rydberg",
symbol = "Ry",
utype = "energy",
scale = 2.1798741e-18,
default = "eV",
link = "Rydberg constant",
},
["scf"] = {
name1 = "standard cubic foot",
name2 = "standard cubic feet",
symbol = "scf",
utype = "energy",
scale = 2869.2044809344,
default = "kJ",
},
["scfoot"] = {
name1 = "standard cubic foot",
name2 = "standard cubic foot",
symbol = "scf",
utype = "energy",
scale = 2869.2044809344,
default = "kJ",
},
["t(TNT)"] = {
name1 = "tonne",
name1_us = "ton",
symbol = "t",
utype = "energy",
scale = 4184000000,
default = "GJ",
link = "TNT equivalent",
},
["TeV"] = {
name1 = "teraelectronvolt",
symbol = "TeV",
utype = "energy",
scale = 1.602176487e-7,
default = "μJ",
link = "Electronvolt",
},
["th"] = {
name1 = "thermie",
symbol = "th",
utype = "energy",
scale = 4186800,
default = "MJ",
link = "Conversion of units#Energy",
},
["thm-EC"] = {
name1 = "therm (EC)",
name2 = "therms (EC)",
symbol = "thm (EC)",
utype = "energy",
scale = 105506000,
default = "MJ",
link = "Therm",
},
["thm-UK"] = {
name1 = "therm (UK)",
name2 = "therms (UK)",
symbol = "thm (UK)",
utype = "energy",
scale = 105505585.257348,
default = "MJ",
link = "Therm",
},
["thm-US"] = {
name1 = "therm (US)",
name1_us = "therm (U.S.)",
name2 = "therms (US)",
name2_us = "therms (U.S.)",
symbol = "thm (US)",
sym_us = "thm (U.S.)",
utype = "energy",
scale = 105480400,
default = "MJ",
link = "Therm",
},
["toe"] = {
name1 = "tonne of oil equivalent",
name2 = "tonnes of oil equivalent",
symbol = "toe",
utype = "energy",
scale = 41868000000,
default = "GJ",
},
["tonTNT"] = {
name2 = "tons of TNT",
symbol = "ton of TNT",
usename = 1,
utype = "energy",
scale = 4184000000,
default = "GJ",
link = "TNT equivalent",
},
["tTNT"] = {
name2 = "tonnes of TNT",
symbol = "tonne of TNT",
usename = 1,
utype = "energy",
scale = 4184000000,
default = "GJ",
link = "TNT equivalent",
},
["TtonTNT"] = {
name2 = "teratons of TNT",
symbol = "teraton of TNT",
usename = 1,
utype = "energy",
scale = 4.184e21,
default = "ZJ",
link = "TNT equivalent",
},
["TtTNT"] = {
name2 = "teratonnes of TNT",
symbol = "teratonne of TNT",
usename = 1,
utype = "energy",
scale = 4.184e21,
default = "ZJ",
link = "TNT equivalent",
},
["TW.h"] = {
name1 = "terawatt-hour",
symbol = "TW⋅h",
utype = "energy",
scale = 3.6e15,
default = "PJ",
link = "Kilowatt-hour",
},
["TWh"] = {
name1 = "terawatt-hour",
symbol = "TWh",
utype = "energy",
scale = 3.6e15,
default = "PJ",
link = "Kilowatt-hour",
},
["W.h"] = {
name1 = "watt-hour",
symbol = "W⋅h",
utype = "energy",
scale = 3600,
default = "kJ",
link = "Kilowatt-hour",
},
["Wh"] = {
name1 = "watt-hour",
symbol = "Wh",
utype = "energy",
scale = 3600,
default = "kJ",
link = "Kilowatt-hour",
},
["μerg"] = {
name1 = "microerg",
symbol = "μerg",
utype = "energy",
scale = 1e-13,
default = "nJ",
link = "Erg",
},
["μeV"] = {
name1 = "microelectronvolt",
symbol = "μeV",
utype = "energy",
scale = 1.602176487e-25,
default = "yJ",
link = "Electronvolt",
},
["μW.h"] = {
name1 = "microwatt-hour",
symbol = "μW⋅h",
utype = "energy",
scale = 0.0036,
default = "mJ",
link = "Kilowatt-hour",
},
["μWh"] = {
name1 = "microwatt-hour",
symbol = "μWh",
utype = "energy",
scale = 0.0036,
default = "mJ",
link = "Kilowatt-hour",
},
["-kW.h"] = {
target = "kW.h",
link = "Kilowatt hour",
},
["btu"] = {
target = "BTU",
},
["Calorie"] = {
target = "Cal",
},
["ft.lbf"] = {
target = "ftlbf",
},
["ft·lbf"] = {
target = "ftlbf",
},
["g-cal-15"] = {
target = "cal-15",
},
["g-cal-IT"] = {
target = "cal-IT",
},
["g-cal-th"] = {
target = "cal-th",
},
["g-kcal-15"] = {
target = "kcal-15",
},
["g-kcal-IT"] = {
target = "kcal-IT",
},
["g-kcal-th"] = {
target = "kcal-th",
},
["g-Mcal-15"] = {
target = "Mcal-15",
},
["g-mcal-15"] = {
target = "mcal-15",
},
["g-Mcal-IT"] = {
target = "Mcal-IT",
},
["g-mcal-IT"] = {
target = "mcal-IT",
},
["g-Mcal-th"] = {
target = "Mcal-th",
},
["g-mcal-th"] = {
target = "mcal-th",
},
["GW-h"] = {
target = "GW.h",
},
["GW·h"] = {
target = "GW.h",
},
["Hartree"] = {
target = "Eh",
},
["hp.h"] = {
target = "hph",
},
["in.lb-f"] = {
target = "inlb-f",
},
["in.lbf"] = {
target = "inlbf",
},
["in.oz-f"] = {
target = "inoz-f",
},
["in.ozf"] = {
target = "inozf",
},
["kbboe"] = {
target = "kBOE",
symbol = "kbboe",
},
["kg-cal-15"] = {
target = "Cal-15",
},
["kg-cal-IT"] = {
target = "Cal-IT",
},
["kg-cal-th"] = {
target = "Cal-th",
},
["kW-h"] = {
target = "kW.h",
},
["kW·h"] = {
target = "kW.h",
},
["MW-h"] = {
target = "MW.h",
},
["mW-h"] = {
target = "mW.h",
},
["MW·h"] = {
target = "MW.h",
},
["TW-h"] = {
target = "TW.h",
},
["uerg"] = {
target = "μerg",
},
["ueV"] = {
target = "μeV",
},
["uW-h"] = {
target = "μW.h",
},
["uW.h"] = {
target = "μW.h",
},
["uWh"] = {
target = "μWh",
},
["W-h"] = {
target = "W.h",
},
["eVpar"] = {
_name1 = "electronvolt",
_symbol = "eV",
utype = "energy per chemical amount",
scale = 96485.329522144166,
prefixes = 1,
default = "kcal/mol",
link = "Electronvolt",
},
["kcal/mol"] = {
per = { "kcal", "mol" },
utype = "energy per chemical amount",
default = "kJ/mol",
link = "Kilocalorie per mole",
},
["kJ/mol"] = {
per = { "kJ", "mol" },
utype = "energy per chemical amount",
default = "kcal/mol",
link = "Joule per mole",
},
["kWh/100 km"] = {
name1 = "kilowatt-hour per 100 kilometres",
name1_us = "kilowatt-hour per 100 kilometers",
name2 = "kilowatt-hours per 100 kilometres",
name2_us = "kilowatt-hours per 100 kilometers",
symbol = "kW⋅h/100 km",
utype = "energy per unit length",
scale = 36,
default = "MJ/km kWh/mi",
link = "Kilowatt-hour",
},
["kWh/100 mi"] = {
name1 = "kilowatt-hour per 100 miles",
name2 = "kilowatt-hours per 100 miles",
symbol = "kW⋅h/100 mi",
utype = "energy per unit length",
scale = 22.3694,
default = "mpge",
link = "Miles per gallon gasoline equivalent",
},
["MJ/100 km"] = {
name1 = "megajoule per 100 kilometres",
name1_us = "megajoule per 100 kilometers",
name2 = "megajoules per 100 kilometres",
name2_us = "megajoules per 100 kilometers",
symbol = "MJ/100 km",
utype = "energy per unit length",
scale = 10,
default = "BTU/mi",
link = "British thermal unit",
},
["mpge"] = {
name1 = "mile per gallon gasoline equivalent",
name2 = "miles per gallon gasoline equivalent",
symbol = "mpg‑e",
utype = "energy per unit length",
scale = 1.3263314048360777e-5,
invert = -1,
iscomplex= true,
default = "kWh/100 mi",
link = "Miles per gallon gasoline equivalent",
},
["BTU/mi"] = {
per = { "BTU", "mi" },
utype = "energy per unit length",
default = "v > 1525 ! M ! k ! J/km",
},
["kJ/km"] = {
per = { "kJ", "km" },
utype = "energy per unit length",
default = "BTU/mi",
},
["kWh/km"] = {
per = { "-kW.h", "km" },
utype = "energy per unit length",
default = "MJ/km kWh/mi",
},
["kWh/mi"] = {
per = { "-kW.h", "mi" },
utype = "energy per unit length",
default = "kWh/km MJ/km",
},
["MJ/km"] = {
per = { "MJ", "km" },
utype = "energy per unit length",
default = "BTU/mi",
},
["mpg-e"] = {
target = "mpge",
},
["BTU/lb"] = {
name1 = "British thermal unit per pound",
name2 = "British thermal units per pound",
symbol = "BTU/lb",
utype = "energy per unit mass",
scale = 2326,
default = "kJ/kg",
link = "British thermal unit",
},
["cal/g"] = {
name1 = "calorie per gram",
name2 = "calories per gram",
symbol = "cal/g",
utype = "energy per unit mass",
scale = 4184,
default = "J/g",
},
["GJ/kg"] = {
name1 = "gigajoule per kilogram",
name2 = "gigajoules per kilogram",
symbol = "GJ/kg",
utype = "energy per unit mass",
scale = 1e9,
default = "ktTNT/t",
link = "Specific energy",
},
["J/g"] = {
name1 = "joule per gram",
name2 = "joules per gram",
symbol = "J/g",
utype = "energy per unit mass",
scale = 1000,
default = "kcal/g",
link = "Specific energy",
},
["kcal/g"] = {
name1 = "kilocalorie per gram",
name2 = "kilocalories per gram",
symbol = "kcal/g",
utype = "energy per unit mass",
scale = 4184000,
default = "kJ/g",
},
["kJ/g"] = {
name1 = "kilojoule per gram",
name2 = "kilojoules per gram",
symbol = "kJ/g",
utype = "energy per unit mass",
scale = 1000000,
default = "kcal/g",
link = "Specific energy",
},
["kJ/kg"] = {
name1 = "kilojoule per kilogram",
name2 = "kilojoules per kilogram",
symbol = "kJ/kg",
utype = "energy per unit mass",
scale = 1000,
default = "BTU/lb",
link = "Specific energy",
},
["ktonTNT/MT"] = {
name2 = "kilotons of TNT per metric ton",
symbol = "kiloton of TNT per metric ton",
usename = 1,
utype = "energy per unit mass",
scale = 4184000000,
default = "GJ/kg",
link = "TNT equivalent",
},
["ktTNT/t"] = {
name2 = "kilotonnes of TNT per tonne",
symbol = "kilotonne of TNT per tonne",
usename = 1,
utype = "energy per unit mass",
scale = 4184000000,
default = "GJ/kg",
link = "TNT equivalent",
},
["MtonTNT/MT"] = {
name2 = "megatons of TNT per metric ton",
symbol = "megaton of TNT per metric ton",
usename = 1,
utype = "energy per unit mass",
scale = 4.184e12,
default = "TJ/kg",
link = "TNT equivalent",
},
["MtTNT/MT"] = {
name2 = "megatonnes of TNT per tonne",
symbol = "megatonne of TNT per tonne",
usename = 1,
utype = "energy per unit mass",
scale = 4.184e12,
default = "TJ/kg",
link = "TNT equivalent",
},
["TJ/kg"] = {
name1 = "terajoule per kilogram",
name2 = "terajoules per kilogram",
symbol = "TJ/kg",
utype = "energy per unit mass",
scale = 1e12,
default = "MtTNT/MT",
link = "Specific energy",
},
["Cal/g"] = {
per = { "Cal", "g" },
utype = "energy per unit mass",
default = "kJ/g",
},
["BTU/cuft"] = {
per = { "BTU", "cuft" },
utype = "energy per unit volume",
default = "kJ/L",
},
["Cal/12USoz(mL)serve"] = {
per = { "Cal", "-12USoz(mL)serve" },
utype = "energy per unit volume",
default = "kJ/L",
},
["Cal/12USoz(ml)serve"] = {
per = { "Cal", "-12USoz(ml)serve" },
utype = "energy per unit volume",
default = "kJ/l",
},
["Cal/12USozserve"] = {
per = { "Cal", "-12USozserve" },
utype = "energy per unit volume",
default = "kJ/L",
},
["Cal/USoz"] = {
per = { "Cal", "USoz" },
utype = "energy per unit volume",
default = "kJ/ml",
},
["kJ/L"] = {
per = { "kJ", "L" },
utype = "energy per unit volume",
default = "BTU/cuft",
},
["kJ/l"] = {
per = { "kJ", "ll" },
utype = "energy per unit volume",
default = "BTU/cuft",
},
["kJ/ml"] = {
per = { "kJ", "ml" },
utype = "energy per unit volume",
default = "Cal/USoz",
},
["MJ/m3"] = {
per = { "MJ", "m3" },
utype = "energy per unit volume",
default = "BTU/cuft",
},
["Sv"] = {
_name1 = "sievert",
_symbol = "Sv",
utype = "equivalent radiation dose",
scale = 1,
prefixes = 1,
default = "rem",
link = "Sievert",
},
["rem"] = {
_name1 = "rem",
_symbol = "rem",
utype = "equivalent radiation dose",
scale = 0.01,
prefixes = 1,
default = "Sv",
link = "Roentgen equivalent man",
},
["g/km"] = {
name1 = "gram per kilometre",
name1_us = "gram per kilometer",
name2 = "grams per kilometre",
name2_us = "grams per kilometer",
symbol = "g/km",
utype = "exhaust emission",
scale = 1e-6,
default = "oz/mi",
link = "Exhaust gas",
},
["g/mi"] = {
name1 = "gram per mile",
name2 = "grams per mile",
symbol = "g/mi",
utype = "exhaust emission",
scale = 6.2137119223733397e-7,
default = "g/km",
link = "Exhaust gas",
},
["gCO2/km"] = {
name1 = "gram of CO<sub>2</sub> per kilometre",
name1_us = "gram of CO<sub>2</sub> per kilometer",
name2 = "grams of CO<sub>2</sub> per kilometre",
name2_us = "grams of CO<sub>2</sub> per kilometer",
symbol = "g(CO<sub>2</sub>)/km",
utype = "exhaust emission",
scale = 1e-6,
default = "ozCO2/mi",
link = "Exhaust gas",
},
["gCO2/mi"] = {
name1 = "gram of CO<sub>2</sub> per mile",
name2 = "grams of CO<sub>2</sub> per mile",
symbol = "g(CO<sub>2</sub>)/mi",
utype = "exhaust emission",
scale = 6.2137119223733397e-7,
default = "gCO2/km",
link = "Exhaust gas",
},
["kg/km"] = {
name1 = "kilogram per kilometre",
name1_us = "kilogram per kilometer",
name2 = "kilograms per kilometre",
name2_us = "kilograms per kilometer",
symbol = "kg/km",
utype = "exhaust emission",
scale = 0.001,
default = "lb/mi",
link = "Exhaust gas",
},
["kgCO2/km"] = {
name1 = "kilogram of CO<sub>2</sub> per kilometre",
name1_us = "kilogram of CO<sub>2</sub> per kilometer",
name2 = "kilograms of CO<sub>2</sub> per kilometre",
name2_us = "kilograms of CO<sub>2</sub> per kilometer",
symbol = "kg(CO<sub>2</sub>)/km",
utype = "exhaust emission",
scale = 0.001,
default = "lbCO2/mi",
link = "Exhaust gas",
},
["lb/mi"] = {
name1 = "pound per mile",
name2 = "pounds per mile",
symbol = "lb/mi",
utype = "exhaust emission",
scale = 0.00028184923173665794,
default = "kg/km",
link = "Exhaust gas",
},
["lbCO2/mi"] = {
name1 = "pound of CO<sub>2</sub> per mile",
name2 = "pounds of CO<sub>2</sub> per mile",
symbol = "lb(CO<sub>2</sub>)/mi",
utype = "exhaust emission",
scale = 0.00028184923173665794,
default = "kgCO2/km",
link = "Exhaust gas",
},
["oz/mi"] = {
name1 = "ounce per mile",
name2 = "ounces per mile",
symbol = "oz/mi",
utype = "exhaust emission",
scale = 1.7615576983541121e-5,
default = "g/km",
link = "Exhaust gas",
},
["ozCO2/mi"] = {
name1 = "ounce of CO<sub>2</sub> per mile",
name2 = "ounces of CO<sub>2</sub> per mile",
symbol = "oz(CO<sub>2</sub>)/mi",
utype = "exhaust emission",
scale = 1.7615576983541121e-5,
default = "gCO2/km",
link = "Exhaust gas",
},
["cuft/a"] = {
name1 = "cubic foot per annum",
name2 = "cubic feet per annum",
symbol = "cu ft/a",
utype = "flow",
scale = 8.9730672142368242e-10,
default = "m3/a",
link = "Cubic foot per second",
},
["cuft/d"] = {
name1 = "cubic foot per day",
name2 = "cubic feet per day",
symbol = "cu ft/d",
utype = "flow",
scale = 3.2774128000000003e-7,
default = "m3/d",
link = "Cubic foot per second",
},
["cuft/h"] = {
name1 = "cubic foot per hour",
name2 = "cubic feet per hour",
symbol = "cu ft/h",
utype = "flow",
scale = 7.8657907200000004e-6,
default = "m3/h",
link = "Cubic foot per second",
},
["cuft/min"] = {
name1 = "cubic foot per minute",
name2 = "cubic feet per minute",
symbol = "cu ft/min",
utype = "flow",
scale = 0.00047194744319999999,
default = "m3/min",
},
["cuft/s"] = {
name1 = "cubic foot per second",
name2 = "cubic feet per second",
symbol = "cu ft/s",
utype = "flow",
scale = 28316846592e-12,
default = "m3/s",
},
["cumi/a"] = {
name1 = "cubic mile per annum",
name2 = "cubic miles per annum",
symbol = "cu mi/a",
utype = "flow",
scale = 132.08171170940057,
default = "km3/a",
link = "Cubic foot per second",
},
["cuyd/h"] = {
name1 = "cubic yard per hour",
name2 = "cubic yards per hour",
symbol = "cuyd/h",
utype = "flow",
scale = 0.00021237634944000001,
default = "m3/h",
link = "Cubic foot per second",
},
["cuyd/s"] = {
name1 = "cubic yard per second",
name2 = "cubic yards per second",
symbol = "cu yd/s",
utype = "flow",
scale = 0.76455485798400002,
default = "m3/s",
},
["Goilbbl/a"] = {
name1 = "billion barrels per year",
name2 = "billion barrels per year",
symbol = "Gbbl/a",
utype = "flow",
scale = 5.0380033629933836,
default = "v * 1.58987294928 < 10 ! e6 ! e9 ! m3/a",
link = "Barrel per day",
},
["impgal/h"] = {
name1 = "imperial gallon per hour",
name2 = "imperial gallons per hour",
symbol = "imp gal/h",
utype = "flow",
scale = 1.2628027777777779e-6,
default = "m3/h",
link = "Gallon",
},
["impgal/min"] = {
name1 = "imperial gallon per minute",
name2 = "imperial gallons per minute",
symbol = "imp gal/min",
utype = "flow",
scale = 7.5768166666666671e-5,
default = "m3/s",
link = "Gallon",
},
["impgal/s"] = {
name1 = "imperial gallon per second",
name2 = "imperial gallons per second",
symbol = "impgal/s",
utype = "flow",
scale = 0.00454609,
default = "m3/s",
link = "Imperial gallons per second",
},
["km3/a"] = {
name1 = "cubic kilometre per annum",
name1_us = "cubic kilometer per annum",
name2 = "cubic kilometres per annum",
name2_us = "cubic kilometers per annum",
symbol = "km<sup>3</sup>/a",
utype = "flow",
scale = 31.68808781402895,
default = "cumi/a",
link = "Cubic metre per second",
},
["km3/d"] = {
name1 = "cubic kilometre per day",
name1_us = "cubic kilometer per day",
name2 = "cubic kilometres per day",
name2_us = "cubic kilometers per day",
symbol = "km<sup>3</sup>/d",
utype = "flow",
scale = 11574.074074074075,
default = "cuft/d",
link = "Cubic metre per second",
},
["koilbbl/a"] = {
name1 = "thousand barrels per year",
name2 = "thousand barrels per year",
symbol = "kbbl/a",
utype = "flow",
scale = 5.0380033629933841e-6,
default = "v * 1.58987294928 < 10 ! ! e3 ! m3/a",
link = "Barrel per day",
},
["koilbbl/d"] = {
name1 = "thousand barrels per day",
name2 = "thousand barrels per day",
symbol = "kbbl/d",
utype = "flow",
scale = 0.0018401307283333335,
default = "v * 1.58987294928 < 10 ! ! e3 ! m3/d",
link = "Barrel per day",
},
["L/h"] = {
name1 = "litre per hour",
name1_us = "liter per hour",
name2 = "litres per hour",
name2_us = "liters per hour",
symbol = "L/h",
utype = "flow",
scale = 2.7777777777777776e-7,
default = "impgal/h USgal/h",
link = "Cubic metre per second",
},
["L/min"] = {
name1 = "litre per minute",
name1_us = "liter per minute",
name2 = "litres per minute",
name2_us = "liters per minute",
symbol = "L/min",
utype = "flow",
scale = 1.6666666666666667e-5,
default = "impgal/min USgal/min",
link = "Cubic metre per second",
},
["L/s"] = {
name1 = "litre per second",
name1_us = "liter per second",
name2 = "litres per second",
name2_us = "liters per second",
symbol = "L/s",
utype = "flow",
scale = 0.001,
default = "cuft/s",
link = "Cubic metre per second",
},
["m3/a"] = {
name1 = "cubic metre per annum",
name1_us = "cubic meter per annum",
name2 = "cubic metres per annum",
name2_us = "cubic meters per annum",
symbol = "m<sup>3</sup>/a",
utype = "flow",
scale = 3.1688087814028947e-8,
default = "cuft/a",
link = "Cubic metre per second",
},
["m3/d"] = {
name1 = "cubic metre per day",
name1_us = "cubic meter per day",
name2 = "cubic metres per day",
name2_us = "cubic meters per day",
symbol = "m<sup>3</sup>/d",
utype = "flow",
scale = 1.1574074074074073e-5,
default = "cuft/d",
link = "Cubic metre per second",
},
["m3/h"] = {
name1 = "cubic metre per hour",
name1_us = "cubic meter per hour",
name2 = "cubic metres per hour",
name2_us = "cubic meters per hour",
symbol = "m<sup>3</sup>/h",
utype = "flow",
scale = 0.00027777777777777778,
default = "cuft/h",
link = "Cubic metre per second",
},
["m3/min"] = {
name1 = "cubic metre per minute",
name1_us = "cubic meter per minute",
name2 = "cubic metres per minute",
name2_us = "cubic meters per minute",
symbol = "m<sup>3</sup>/min",
utype = "flow",
scale = 0.016666666666666666,
default = "cuft/min",
link = "Cubic metre per second",
},
["m3/s"] = {
name1 = "cubic metre per second",
name1_us = "cubic meter per second",
name2 = "cubic metres per second",
name2_us = "cubic meters per second",
symbol = "m<sup>3</sup>/s",
utype = "flow",
scale = 1,
default = "cuft/s",
},
["Moilbbl/a"] = {
name1 = "million barrels per year",
name2 = "million barrels per year",
symbol = "Mbbl/a",
utype = "flow",
scale = 0.0050380033629933837,
default = "v * 1.58987294928 < 10 ! e3 ! e6 ! m3/a",
link = "Barrel per day",
},
["Moilbbl/d"] = {
name1 = "million barrels per day",
name2 = "million barrels per day",
symbol = "Mbbl/d",
utype = "flow",
scale = 1.8401307283333335,
default = "v * 1.58987294928 < 10 ! e3 ! e6 ! m3/d",
link = "Barrel per day",
},
["oilbbl/a"] = {
name1 = "barrel per year",
name2 = "barrels per year",
symbol = "bbl/a",
utype = "flow",
scale = 5.0380033629933841e-9,
default = "m3/a",
link = "Barrel per day",
},
["oilbbl/d"] = {
name1 = "barrel per day",
name2 = "barrels per day",
symbol = "bbl/d",
utype = "flow",
scale = 1.8401307283333336e-6,
default = "m3/d",
},
["Toilbbl/a"] = {
name1 = "trillion barrels per year",
name2 = "trillion barrels per year",
symbol = "Tbbl/a",
utype = "flow",
scale = 5038.0033629933832,
default = "v * 1.58987294928 < 10 ! e9 ! e12 ! m3/a",
link = "Barrel per day",
},
["U.S.gal/d"] = {
name1 = "U.S. gallon per day",
name2 = "U.S. gallons per day",
symbol = "U.S. gal/d",
utype = "flow",
scale = 4.3812636388888893e-8,
default = "m3/s",
customary= 1,
},
["U.S.gal/h"] = {
name1 = "gallon per hour",
name2 = "gallons per hour",
symbol = "gal/h",
utype = "flow",
scale = 1.0515032733333334e-6,
default = "m3/h",
link = "Gallon",
customary= 2,
},
["U.S.gal/min"] = {
name1 = "U.S. gallon per minute",
name2 = "U.S. gallons per minute",
symbol = "U.S. gal/min",
utype = "flow",
scale = 6.3090196400000003e-5,
default = "m3/s",
link = "Gallon",
},
["USgal/a"] = {
name1 = "US gallon per year",
name2 = "US gallons per year",
symbol = "US gal/a",
utype = "flow",
scale = 1.1995246102365199e-10,
default = "m3/s",
},
["USgal/d"] = {
name1 = "US gallon per day",
name2 = "US gallons per day",
symbol = "US gal/d",
utype = "flow",
scale = 4.3812636388888893e-8,
default = "m3/s",
},
["USgal/h"] = {
name1 = "gallon per hour",
name2 = "gallons per hour",
symbol = "gal/h",
utype = "flow",
scale = 1.0515032733333334e-6,
default = "m3/h",
link = "Gallon",
customary= 1,
},
["USgal/min"] = {
name1 = "US gallon per minute",
name2 = "US gallons per minute",
symbol = "US gal/min",
utype = "flow",
scale = 6.3090196400000003e-5,
default = "m3/s",
link = "Gallon",
},
["USgal/s"] = {
name1 = "US gallon per second",
name1_us = "U.S. gallon per second",
name2 = "US gallons per second",
name2_us = "U.S. gallons per second",
symbol = "USgal/s",
utype = "flow",
scale = 0.003785411784,
default = "m3/s",
link = "US gallons per second",
},
["ft3/a"] = {
target = "cuft/a",
},
["ft3/d"] = {
target = "cuft/d",
},
["ft3/h"] = {
target = "cuft/h",
},
["ft3/s"] = {
target = "cuft/s",
},
["Gcuft/a"] = {
target = "e9cuft/a",
},
["Gcuft/d"] = {
target = "e9cuft/d",
},
["kcuft/a"] = {
target = "e3cuft/a",
},
["kcuft/d"] = {
target = "e3cuft/d",
},
["kcuft/s"] = {
target = "e3cuft/s",
},
["Mcuft/a"] = {
target = "e6cuft/a",
},
["Mcuft/d"] = {
target = "e6cuft/d",
},
["Mcuft/s"] = {
target = "e6cuft/s",
},
["m³/s"] = {
target = "m3/s",
},
["Tcuft/a"] = {
target = "e12cuft/a",
},
["Tcuft/d"] = {
target = "e12cuft/d",
},
["u.s.gal/min"] = {
target = "U.S.gal/min",
},
["usgal/min"] = {
target = "USgal/min",
},
["-LTf"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "LTf",
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["-STf"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "STf",
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["dyn"] = {
name1 = "dyne",
symbol = "dyn",
utype = "force",
scale = 0.00001,
default = "gr-f",
},
["g-f"] = {
name1 = "gram-force",
name2 = "grams-force",
symbol = "g<sub>f</sub>",
utype = "force",
scale = 0.00980665,
default = "mN oz-f",
link = "Kilogram-force",
},
["gf"] = {
name1 = "gram-force",
name2 = "grams-force",
symbol = "gf",
utype = "force",
scale = 0.00980665,
default = "mN ozf",
link = "Kilogram-force",
},
["gr-f"] = {
name1 = "grain-force",
name2 = "grains-force",
symbol = "gr<sub>f</sub>",
utype = "force",
scale = 0.0006354602307515,
default = "μN",
link = "Pound (force)",
},
["grf"] = {
name1 = "grain-force",
name2 = "grains-force",
symbol = "grf",
utype = "force",
scale = 0.0006354602307515,
default = "μN",
link = "Pound (force)",
},
["kdyn"] = {
name1 = "kilodyne",
symbol = "kdyn",
utype = "force",
scale = 0.01,
default = "oz-f",
link = "Dyne",
},
["kg-f"] = {
name1 = "kilogram-force",
name2 = "kilograms-force",
symbol = "kg<sub>f</sub>",
utype = "force",
scale = 9.80665,
default = "N lb-f",
},
["kgf"] = {
name1 = "kilogram-force",
name2 = "kilograms-force",
symbol = "kgf",
utype = "force",
scale = 9.80665,
default = "N lbf",
},
["kp"] = {
name1 = "kilopond",
symbol = "kp",
utype = "force",
scale = 9.80665,
default = "N lb-f",
link = "Kilogram-force",
},
["L/T-f"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "L/T<sub>f</sub>",
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["L/Tf"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "L/Tf",
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["lb-f"] = {
name1 = "pound-force",
name2 = "pounds-force",
symbol = "lb<sub>f</sub>",
utype = "force",
scale = 4.4482216152605,
default = "N",
link = "Pound (force)",
},
["lbf"] = {
name1 = "pound-force",
name2 = "pounds-force",
symbol = "lbf",
utype = "force",
scale = 4.4482216152605,
default = "N",
link = "Pound (force)",
},
["lb(f)"] = {
name1 = "pound",
symbol = "lb",
utype = "force",
scale = 4.4482216152605,
default = "N",
link = "Pound (force)",
},
["LT-f"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "LT<sub>f</sub>",
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["LTf"] = {
name1 = "long ton-force",
name2 = "long tons-force",
symbol = "LTf",
usename = 1,
utype = "force",
scale = 9964.01641818352,
default = "kN",
},
["Mdyn"] = {
name1 = "megadyne",
symbol = "Mdyn",
utype = "force",
scale = 10,
default = "lb-f",
link = "Dyne",
},
["mdyn"] = {
name1 = "millidyne",
symbol = "mdyn",
utype = "force",
scale = 0.00000001,
default = "gr-f",
link = "Dyne",
},
["mg-f"] = {
name1 = "milligram-force",
name2 = "milligrams-force",
symbol = "mg<sub>f</sub>",
utype = "force",
scale = 0.00000980665,
default = "μN gr-f",
link = "Kilogram-force",
},
["mgf"] = {
name1 = "milligram-force",
name2 = "milligrams-force",
symbol = "mgf",
utype = "force",
scale = 0.00000980665,
default = "μN grf",
link = "Kilogram-force",
},
["Mp"] = {
name1 = "megapond",
symbol = "Mp",
utype = "force",
scale = 9806.65,
default = "kN LT-f ST-f",
link = "Kilogram-force",
},
["mp"] = {
name1 = "millipond",
symbol = "mp",
utype = "force",
scale = 0.00000980665,
default = "μN gr-f",
link = "Kilogram-force",
},
["N"] = {
_name1 = "newton",
_symbol = "N",
utype = "force",
scale = 1,
prefixes = 1,
default = "lb-f",
link = "Newton (unit)",
},
["oz-f"] = {
name1 = "ounce-force",
name2 = "ounces-force",
symbol = "oz<sub>f</sub>",
utype = "force",
scale = 0.2780138203095378125,
default = "mN",
link = "Pound (force)",
},
["ozf"] = {
name1 = "ounce-force",
name2 = "ounces-force",
symbol = "ozf",
utype = "force",
scale = 0.2780138203095378125,
default = "mN",
link = "Pound (force)",
},
["p"] = {
name1 = "pond",
symbol = "p",
utype = "force",
scale = 0.00980665,
default = "mN oz-f",
link = "Kilogram-force",
},
["pdl"] = {
name1 = "poundal",
symbol = "pdl",
utype = "force",
scale = 0.138254954376,
default = "N",
},
["S/T-f"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "S/T<sub>f</sub>",
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["S/Tf"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "S/Tf",
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["ST-f"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "ST<sub>f</sub>",
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["STf"] = {
name1 = "short ton-force",
name2 = "short tons-force",
symbol = "STf",
usename = 1,
utype = "force",
scale = 8896.443230521,
default = "kN",
},
["t-f"] = {
name1 = "tonne-force",
name2 = "tonnes-force",
symbol = "t<sub>f</sub>",
utype = "force",
scale = 9806.65,
default = "kN LT-f ST-f",
link = "Ton-force#Tonne-force",
},
["tf"] = {
name1 = "tonne-force",
name2 = "tonnes-force",
symbol = "tf",
utype = "force",
scale = 9806.65,
default = "kN LTf STf",
link = "Ton-force#Tonne-force",
},
["dyne"] = {
target = "dyn",
},
["newtons"] = {
target = "N",
},
["poundal"] = {
target = "pdl",
},
["tonne-force"] = {
target = "tf",
},
["impgal/mi"] = {
per = { "@impgal", "mi" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "L/km USgal/mi",
},
["km/L"] = {
per = { "km", "L" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "mpgimp mpgus",
},
["km/l"] = {
per = { "km", "ll" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "mpgimp mpgus",
},
["L/100 km"] = {
per = { "L", "100km" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "mpgimp mpgus",
symlink = "[[Fuel economy in automobiles#Units of measure|L/100 km]]",
},
["l/100 km"] = {
per = { "ll", "100km" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "mpgimp mpgus",
symlink = "[[Fuel economy in automobiles#Units of measure|l/100 km]]",
},
["L/km"] = {
per = { "L", "km" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "mpgimp mpgus",
},
["l/km"] = {
per = { "ll", "km" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "mpgimp mpgus",
},
["mi/impqt"] = {
per = { "mi", "impqt" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "km/L",
},
["mi/U.S.qt"] = {
per = { "mi", "U.S.qt" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "km/L",
},
["mi/USqt"] = {
per = { "mi", "USqt" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "km/L",
},
["mi/usqt"] = {
per = { "mi", "usqt" },
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "km/L",
},
["mpgimp"] = {
per = { "mi", "@impgal" },
symbol = "mpg<sub>‑imp</sub>",
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "L/100 km+mpgus",
symlink = "[[Fuel economy in automobiles#Units of measure|mpg]]<sub>‑[[Imperial units|imp]]</sub>",
},
["mpgus"] = {
per = { "mi", "+USgal" },
symbol = "mpg<sub>‑US</sub>",
utype = "fuel efficiency",
invert = -1,
iscomplex= true,
default = "L/100 km+mpgimp",
symlink = "[[Fuel economy in automobiles#Units of measure|mpg]]<sub>‑[[United States customary units|US]]</sub>",
},
["U.S.gal/mi"] = {
per = { "*U.S.gal", "mi" },
sp_us = true,
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "L/km impgal/mi",
},
["usgal/mi"] = {
per = { "+USgal", "mi" },
utype = "fuel efficiency",
invert = 1,
iscomplex= true,
default = "L/km impgal/mi",
},
["L/100km"] = {
target = "L/100 km",
},
["l/100km"] = {
target = "l/100 km",
},
["mpg"] = {
shouldbe = "Use %{mpgus%} for miles per US gallon or %{mpgimp%} for miles per imperial gallon (not %{mpg%})",
},
["mpgU.S."] = {
target = "mpgus",
symbol = "mpg<sub>‑U.S.</sub>",
sp_us = true,
symlink = "[[Fuel economy in automobiles#Units of measure|mpg]]<sub>‑[[United States customary units|U.S.]]</sub>",
},
["mpgu.s."] = {
target = "mpgus",
symbol = "mpg<sub>‑U.S.</sub>",
sp_us = true,
symlink = "[[Fuel economy in automobiles#Units of measure|mpg]]<sub>‑[[United States customary units|U.S.]]</sub>",
},
["mpgUS"] = {
target = "mpgus",
},
["USgal/mi"] = {
target = "usgal/mi",
},
["kPa/m"] = {
per = { "kPa", "-m-frac" },
utype = "fracture gradient",
default = "psi/ft",
},
["psi/ft"] = {
per = { "psi", "-ft-frac" },
utype = "fracture gradient",
default = "kPa/m",
},
["cm/km"] = {
name1 = "centimetre per kilometre",
name1_us = "centimeter per kilometer",
name2 = "centimetres per kilometre",
name2_us = "centimeters per kilometer",
symbol = "cm/km",
utype = "gradient",
scale = 0.00001,
default = "ft/mi",
link = "Grade (slope)",
},
["ft/mi"] = {
name1 = "foot per mile",
name2 = "feet per mile",
symbol = "ft/mi",
utype = "gradient",
scale = 0.00018939393939393939,
default = "v < 5.28 ! c ! ! m/km",
link = "Grade (slope)",
},
["ft/nmi"] = {
name1 = "foot per nautical mile",
name2 = "feet per nautical mile",
symbol = "ft/nmi",
utype = "gradient",
scale = 0.00016457883369330455,
default = "v < 6.076 ! c ! ! m/km",
link = "Grade (slope)",
},
["in/ft"] = {
name1 = "inch per foot",
name2 = "inches per foot",
symbol = "in/ft",
utype = "gradient",
scale = 0.083333333333333329,
default = "mm/m",
link = "Grade (slope)",
},
["in/mi"] = {
name1 = "inch per mile",
name2 = "inches per mile",
symbol = "in/mi",
utype = "gradient",
scale = 1.5782828282828283e-5,
default = "v < 0.6336 ! m ! c ! m/km",
link = "Grade (slope)",
},
["m/km"] = {
name1 = "metre per kilometre",
name1_us = "meter per kilometer",
name2 = "metres per kilometre",
name2_us = "meters per kilometer",
symbol = "m/km",
utype = "gradient",
scale = 0.001,
default = "ft/mi",
link = "Grade (slope)",
},
["mm/km"] = {
name1 = "millimetre per kilometre",
name1_us = "millimeter per kilometer",
name2 = "millimetres per kilometre",
name2_us = "millimeters per kilometer",
symbol = "mm/km",
utype = "gradient",
scale = 0.000001,
default = "in/mi",
link = "Grade (slope)",
},
["mm/m"] = {
name1 = "millimetre per metre",
name1_us = "millimeter per meter",
name2 = "millimetres per metre",
name2_us = "millimeters per meter",
symbol = "mm/m",
utype = "gradient",
scale = 0.001,
default = "in/ft",
link = "Grade (slope)",
},
["admi"] = {
name1 = "admiralty mile",
symbol = "nmi (admiralty)",
utype = "length",
scale = 1853.184,
default = "km mi",
link = "Nautical mile",
},
["AU"] = {
name1 = "astronomical unit",
symbol = "AU",
utype = "length",
scale = 149597870700,
default = "km mi",
},
["Brnmi"] = {
name1 = "British nautical mile",
symbol = "(Brit) nmi",
utype = "length",
scale = 1853.184,
default = "km mi",
link = "Nautical mile",
},
["bu"] = {
name2 = "bu",
symbol = "bu",
usename = 1,
utype = "length",
scale = 0.0030303030303030303,
default = "mm",
link = "Japanese units of measurement#Length",
},
["ch"] = {
name1 = "chain",
symbol = "ch",
utype = "length",
scale = 20.1168,
default = "ft m",
subdivs = { ["ft"] = { 66, default = "m" }, ["yd"] = { 22, default = "m" } },
link = "Chain (unit)",
},
["chlk"] = {
name1 = "[[Chain (unit)|chain]]",
symbol = "[[Chain (unit)|ch]]",
utype = "length",
scale = 20.1168,
default = "ft m",
link = "",
},
["chain"] = {
symbol = "chain",
usename = 1,
utype = "length",
scale = 20.1168,
default = "ft m",
subdivs = { ["ft"] = { 66, default = "m" }, ["yd"] = { 22, default = "m" } },
link = "Chain (unit)",
},
["chainlk"] = {
symbol = "[[Chain (unit)|chain]]",
usename = 1,
utype = "length",
scale = 20.1168,
default = "ft m",
link = "",
},
["dpcm"] = {
name2 = "dot/cm",
symbol = "dot/cm",
utype = "length",
scale = 100,
invert = -1,
iscomplex= true,
default = "dpi",
link = "Dots per inch",
},
["dpi"] = {
name2 = "DPI",
symbol = "DPI",
utype = "length",
scale = 39.370078740157481,
invert = -1,
iscomplex= true,
default = "pitch",
link = "Dots per inch",
},
["fathom"] = {
symbol = "fathom",
usename = 1,
utype = "length",
scale = 1.8288,
default = "ft m",
},
["foot"] = {
name1 = "foot",
name2 = "foot",
symbol = "ft",
utype = "length",
scale = 0.3048,
default = "m",
subdivs = { ["in"] = { 12, default = "m" } },
link = "Foot (unit)",
},
["ft"] = {
name1 = "foot",
name2 = "feet",
symbol = "ft",
utype = "length",
scale = 0.3048,
exception= "integer_more_precision",
default = "m",
subdivs = { ["in"] = { 12, default = "m" } },
link = "Foot (unit)",
},
["furlong"] = {
symbol = "furlong",
usename = 1,
utype = "length",
scale = 201.168,
default = "ft m",
},
["Gly"] = {
name1 = "gigalight-year",
symbol = "Gly",
utype = "length",
scale = 9.4607304725808e24,
default = "Mpc",
link = "Light-year#Definitions",
},
["Gpc"] = {
name1 = "gigaparsec",
symbol = "Gpc",
utype = "length",
scale = 3.0856775814671916e25,
default = "Gly",
link = "Parsec#Megaparsecs and gigaparsecs",
},
["hand"] = {
name1 = "hand",
symbol = "h",
utype = "length",
builtin = "hand",
scale = 0.1016,
iscomplex= true,
default = "in cm",
link = "Hand (unit)",
},
["in"] = {
name1 = "inch",
name2 = "inches",
symbol = "in",
utype = "length",
scale = 0.0254,
exception= "subunit_more_precision",
default = "mm",
},
["inabbreviated"] = {
name2 = "in",
symbol = "in",
utype = "length",
scale = 0.0254,
default = "mm",
link = "Inch",
},
["kly"] = {
name1 = "kilolight-year",
symbol = "kly",
utype = "length",
scale = 9.4607304725808e18,
default = "pc",
link = "Light-year#Definitions",
},
["kpc"] = {
name1 = "kiloparsec",
symbol = "kpc",
utype = "length",
scale = 3.0856775814671916e19,
default = "kly",
link = "Parsec#Parsecs and kiloparsecs",
},
["LD"] = {
name1 = "lunar distance",
symbol = "LD",
utype = "length",
scale = 384403000,
default = "km mi",
link = "Lunar distance (astronomy)",
},
["league"] = {
symbol = "league",
usename = 1,
utype = "length",
scale = 4828.032,
default = "km",
link = "League (unit)",
},
["ly"] = {
name1 = "light-year",
symbol = "ly",
utype = "length",
scale = 9.4607304725808e15,
default = "AU",
},
["m"] = {
_name1 = "metre",
_name1_us= "meter",
_symbol = "m",
utype = "length",
scale = 1,
prefixes = 1,
default = "v > 0 and v < 3 ! ftin ! ft",
link = "Metre",
},
["mi"] = {
name1 = "mile",
symbol = "mi",
utype = "length",
scale = 1609.344,
default = "km",
subdivs = { ["ch"] = { 80, default = "km" }, ["chlk"] = { 80, default = "km" }, ["chain"] = { 80, default = "km" }, ["chainlk"] = { 80, default = "km" }, ["ft"] = { 5280, default = "km" }, ["furlong"] = { 8, default = "km" }, ["yd"] = { 1760, default = "km" } },
},
["mil"] = {
symbol = "mil",
usename = 1,
utype = "length",
scale = 0.0000254,
default = "mm",
link = "Thousandth of an inch",
},
["Mly"] = {
name1 = "megalight-year",
symbol = "Mly",
utype = "length",
scale = 9.4607304725808e21,
default = "kpc",
link = "Light-year#Definitions",
},
["Mpc"] = {
name1 = "megaparsec",
symbol = "Mpc",
utype = "length",
scale = 3.0856775814671916e22,
default = "Mly",
link = "Parsec#Megaparsecs and gigaparsecs",
},
["NM"] = {
name1 = "nautical mile",
symbol = "NM",
utype = "length",
scale = 1852,
default = "km mi",
},
["nmi"] = {
name1 = "nautical mile",
symbol = "nmi",
utype = "length",
scale = 1852,
default = "km mi",
},
["oldUKnmi"] = {
name1 = "nautical mile",
symbol = "nmi",
utype = "length",
scale = 1853.184,
default = "km mi",
},
["oldUSnmi"] = {
name1 = "nautical mile",
symbol = "nmi",
utype = "length",
scale = 1853.24496,
default = "km mi",
},
["pc"] = {
name1 = "parsec",
symbol = "pc",
utype = "length",
scale = 3.0856775814671916e16,
default = "ly",
},
["perch"] = {
name2 = "perches",
symbol = "perch",
usename = 1,
utype = "length",
scale = 5.0292,
default = "ft m",
link = "Rod (unit)",
},
["pitch"] = {
name2 = "μm",
symbol = "μm",
utype = "length",
scale = 1e-6,
default = "dpi",
defkey = "pitch",
linkey = "pitch",
link = "Dots per inch",
},
["pole"] = {
symbol = "pole",
usename = 1,
utype = "length",
scale = 5.0292,
default = "ft m",
link = "Rod (unit)",
},
["pre1954U.S.nmi"] = {
name1 = "(pre-1954 U.S.) nautical mile",
symbol = "(pre‑1954 U.S.) nmi",
utype = "length",
scale = 1853.24496,
default = "km mi",
link = "Nautical mile",
},
["pre1954USnmi"] = {
name1 = "(pre-1954 US) nautical mile",
name1_us = "(pre-1954 U.S.) nautical mile",
symbol = "(pre‑1954 US) nmi",
sym_us = "(pre‑1954 U.S.) nmi",
utype = "length",
scale = 1853.24496,
default = "km mi",
link = "Nautical mile",
},
["rd"] = {
name1 = "rod",
symbol = "rd",
utype = "length",
scale = 5.0292,
default = "ft m",
link = "Rod (unit)",
},
["royal cubit"] = {
name1 = "royal cubit",
symbol = "cu",
utype = "length",
scale = 0.524,
default = "mm",
},
["rtkm"] = {
name1 = "route kilometre",
name1_us = "route kilometer",
symbol = "km",
utype = "length",
scale = 1000,
default = "mi",
link = "Kilometre",
},
["rtmi"] = {
name1 = "route mile",
symbol = "mi",
utype = "length",
scale = 1609.344,
default = "km",
link = "Mile",
},
["shaku"] = {
name2 = "shaku",
symbol = "shaku",
usename = 1,
utype = "length",
scale = 0.30303030303030304,
default = "m",
link = "Shaku (unit)",
},
["sm"] = {
name1 = "smoot",
symbol = "sm",
utype = "length",
scale = 1.70180,
default = "m",
link = "Smoot (unit)",
},
["smi"] = {
name1 = "statute mile",
symbol = "mi",
utype = "length",
scale = 1609.344,
default = "km",
subdivs = { ["chain"] = { 80, default = "km" } },
},
["solar radius"] = {
name1 = "solar radius",
name2 = "solar radii",
symbol = "''R''<sub>☉</sub>",
utype = "length",
scale = 695700e3,
default = "km",
},
["sun"] = {
name2 = "sun",
symbol = "sun",
usename = 1,
utype = "length",
scale = 0.030303030303030304,
default = "mm",
link = "Japanese units of measurement#Length",
},
["thou"] = {
name2 = "thou",
symbol = "thou",
usename = 1,
utype = "length",
scale = 0.0000254,
default = "mm",
link = "Thousandth of an inch",
},
["verst"] = {
symbol = "verst",
usename = 1,
utype = "length",
scale = 1066.8,
default = "km mi",
},
["yd"] = {
name1 = "yard",
symbol = "yd",
utype = "length",
scale = 0.9144,
default = "m",
subdivs = { ["ft"] = { 3, default = "m" } },
},
["μin"] = {
name1 = "microinch",
name2 = "microinches",
symbol = "μin",
utype = "length",
scale = 0.0000000254,
default = "nm",
link = "SI prefix#Non-metric units",
},
["Å"] = {
name1 = "ångström",
symbol = "Å",
utype = "length",
scale = 0.0000000001,
default = "in",
},
["Hz"] = {
_name1 = "hertz",
_name2 = "hertz",
_symbol = "Hz",
utype = "length",
scale = 3.3356409519815204e-9,
invert = -1,
iscomplex= true,
prefixes = 1,
default = "m",
link = "Hertz",
},
["rpm"] = {
name1 = "revolution per minute",
name2 = "revolutions per minute",
symbol = "rpm",
utype = "length",
scale = 5.5594015866358675e-11,
invert = -1,
iscomplex= true,
default = "Hz",
link = "Revolutions per minute",
},
["-ft-frac"] = {
target = "ft",
link = "Fracture gradient",
},
["-in-stiff"] = {
target = "in",
link = "Stiffness",
},
["-m-frac"] = {
target = "m",
link = "Fracture gradient",
},
["-m-stiff"] = {
target = "m",
link = "Stiffness",
},
["100km"] = {
target = "km",
multiplier= 100,
},
["100mi"] = {
target = "mi",
multiplier= 100,
},
["100miles"] = {
target = "mi",
symbol = "miles",
multiplier= 100,
},
["admiralty nmi"] = {
target = "oldUKnmi",
},
["angstrom"] = {
target = "Å",
},
["au"] = {
target = "AU",
symbol = "au",
},
["feet"] = {
target = "ft",
},
["hands"] = {
target = "hand",
},
["inch"] = {
target = "in",
},
["inches"] = {
target = "in",
},
["light-year"] = {
target = "ly",
},
["meter"] = {
target = "m",
sp_us = true,
},
["meters"] = {
target = "m",
sp_us = true,
},
["metre"] = {
target = "m",
},
["metres"] = {
target = "m",
},
["micrometre"] = {
target = "μm",
},
["micron"] = {
target = "μm",
default = "μin",
},
["mile"] = {
target = "mi",
},
["miles"] = {
target = "mi",
},
["parsec"] = {
target = "pc",
},
["rod"] = {
target = "rd",
},
["smoot"] = {
target = "sm",
},
["uin"] = {
target = "μin",
},
["yard"] = {
target = "yd",
},
["yards"] = {
target = "yd",
},
["yds"] = {
target = "yd",
},
["dtex"] = {
name1 = "decitex",
name2 = "decitex",
symbol = "dtex",
utype = "linear density",
scale = 1e-7,
default = "lb/yd",
link = "Units of textile measurement#Units",
},
["kg/cm"] = {
name1 = "kilogram per centimetre",
name1_us = "kilogram per centimeter",
name2 = "kilograms per centimetre",
name2_us = "kilograms per centimeter",
symbol = "kg/cm",
utype = "linear density",
scale = 100,
default = "lb/yd",
link = "Linear density",
},
["kg/m"] = {
name1 = "kilogram per metre",
name1_us = "kilogram per meter",
name2 = "kilograms per metre",
name2_us = "kilograms per meter",
symbol = "kg/m",
utype = "linear density",
scale = 1,
default = "lb/yd",
link = "Linear density",
},
["lb/ft"] = {
name1 = "pound per foot",
name2 = "pounds per foot",
symbol = "lb/ft",
utype = "linear density",
scale = 1.4881639435695539,
default = "kg/m",
link = "Linear density",
},
["lb/yd"] = {
name1 = "pound per yard",
name2 = "pounds per yard",
symbol = "lb/yd",
utype = "linear density",
scale = 0.49605464785651798,
default = "kg/m",
link = "Linear density",
},
["G"] = {
_name1 = "gauss",
_name2 = "gauss",
_symbol = "G",
utype = "magnetic field strength",
scale = 0.0001,
prefixes = 1,
default = "T",
link = "Gauss (unit)",
},
["T"] = {
_name1 = "tesla",
_symbol = "T",
utype = "magnetic field strength",
scale = 1,
prefixes = 1,
default = "G",
link = "Tesla (unit)",
},
["A/m"] = {
name1 = "ampere per metre",
name1_us = "ampere per meter",
name2 = "amperes per metre",
name2_us = "amperes per meter",
symbol = "A/m",
utype = "magnetizing field",
scale = 1,
default = "Oe",
},
["kA/m"] = {
name1 = "kiloampere per metre",
name1_us = "kiloampere per meter",
name2 = "kiloamperes per metre",
name2_us = "kiloamperes per meter",
symbol = "kA/m",
utype = "magnetizing field",
scale = 1000,
default = "kOe",
link = "Ampere per metre",
},
["MA/m"] = {
name1 = "megaampere per metre",
name1_us = "megaampere per meter",
name2 = "megaamperes per metre",
name2_us = "megaamperes per meter",
symbol = "MA/m",
utype = "magnetizing field",
scale = 1e6,
default = "kOe",
link = "Ampere per metre",
},
["Oe"] = {
_name1 = "oersted",
_symbol = "Oe",
utype = "magnetizing field",
scale = 79.5774715,
prefixes = 1,
default = "kA/m",
link = "Oersted",
},
["-Lcwt"] = {
name1 = "hundredweight",
name2 = "hundredweight",
symbol = "cwt",
utype = "mass",
scale = 50.80234544,
default = "lb",
},
["-Scwt"] = {
name1 = "hundredweight",
name2 = "hundredweight",
symbol = "cwt",
utype = "mass",
scale = 45.359237,
default = "lb",
},
["-ST"] = {
name1 = "short ton",
symbol = "ST",
utype = "mass",
scale = 907.18474,
default = "t",
},
["carat"] = {
symbol = "carat",
usename = 1,
utype = "mass",
scale = 0.0002,
default = "g",
link = "Carat (mass)",
},
["drachm"] = {
name1_us = "dram",
symbol = "drachm",
usename = 1,
utype = "mass",
scale = 0.001771845195,
default = "g",
link = "Dram (unit)",
},
["dram"] = {
target = "drachm",
},
["dwt"] = {
name1 = "pennyweight",
symbol = "dwt",
utype = "mass",
scale = 0.00155517384,
default = "oz g",
},
["DWton"] = {
symbol = "deadweight ton",
usename = 1,
utype = "mass",
scale = 1016.0469088,
default = "DWtonne",
link = "Deadweight tonnage",
},
["DWtonne"] = {
name1_us = "deadweight metric ton",
symbol = "deadweight tonne",
sym_us = "~deadweight metric ton",
usename = 1,
utype = "mass",
scale = 1000,
default = "DWton",
link = "Deadweight tonnage",
},
["g"] = {
_name1 = "gram",
_symbol = "g",
utype = "mass",
scale = 0.001,
prefixes = 1,
default = "oz",
link = "Gram",
},
["gr"] = {
name1 = "grain",
symbol = "gr",
utype = "mass",
scale = 0.00006479891,
default = "g",
link = "Grain (unit)",
},
["Gt"] = {
name1 = "gigatonne",
symbol = "Gt",
utype = "mass",
scale = 1000000000000,
default = "LT ST",
link = "Tonne",
},
["impgalh2o"] = {
name1 = "imperial gallon of water",
name2 = "imperial gallons of water",
symbol = "imp gal H<sub>2</sub>O",
utype = "mass",
scale = 4.5359236999999499,
default = "lb kg",
link = "Imperial gallon",
},
["kt"] = {
name1 = "kilotonne",
symbol = "kt",
utype = "mass",
scale = 1000000,
default = "LT ST",
link = "Tonne",
},
["lb"] = {
name1 = "pound",
symbol = "lb",
utype = "mass",
scale = 0.45359237,
exception= "integer_more_precision",
default = "kg",
subdivs = { ["oz"] = { 16, default = "kg" } },
link = "Pound (mass)",
},
["Lcwt"] = {
name1 = "long hundredweight",
name2 = "long hundredweight",
symbol = "Lcwt",
usename = 1,
utype = "mass",
scale = 50.80234544,
default = "lb",
subdivs = { ["qtr"] = { 4, default = "kg" }, ["st"] = { 8, default = "kg" } },
link = "Hundredweight",
},
["long cwt"] = {
name1 = "long hundredweight",
name2 = "long hundredweight",
symbol = "long cwt",
utype = "mass",
scale = 50.80234544,
default = "lb kg",
subdivs = { ["qtr"] = { 4, default = "kg" } },
link = "Hundredweight",
},
["long qtr"] = {
name1 = "long quarter",
symbol = "long qtr",
utype = "mass",
scale = 12.70058636,
default = "lb kg",
},
["LT"] = {
symbol = "long ton",
usename = 1,
utype = "mass",
scale = 1016.0469088,
default = "t",
subdivs = { ["Lcwt"] = { 20, default = "t", unit = "-Lcwt" } },
},
["lt"] = {
name1 = "long ton",
symbol = "LT",
utype = "mass",
scale = 1016.0469088,
default = "t",
subdivs = { ["Lcwt"] = { 20, default = "t", unit = "-Lcwt" } },
},
["metric ton"] = {
symbol = "metric ton",
usename = 1,
utype = "mass",
scale = 1000,
default = "long ton",
link = "Tonne",
},
["MT"] = {
name1 = "metric ton",
symbol = "t",
utype = "mass",
scale = 1000,
default = "LT ST",
link = "Tonne",
},
["Mt"] = {
name1 = "megatonne",
symbol = "Mt",
utype = "mass",
scale = 1000000000,
default = "LT ST",
link = "Tonne",
},
["oz"] = {
name1 = "ounce",
symbol = "oz",
utype = "mass",
scale = 0.028349523125,
default = "g",
},
["ozt"] = {
name1 = "troy ounce",
symbol = "ozt",
utype = "mass",
scale = 0.0311034768,
default = "oz g",
},
["pdr"] = {
name1 = "pounder",
symbol = "pdr",
utype = "mass",
scale = 0.45359237,
default = "kg",
link = "Pound (mass)",
},
["qtr"] = {
name1 = "quarter",
symbol = "qtr",
utype = "mass",
scale = 12.70058636,
default = "lb kg",
subdivs = { ["lb"] = { 28, default = "kg" } },
link = "Long quarter",
},
["Scwt"] = {
name1 = "short hundredweight",
name2 = "short hundredweight",
symbol = "Scwt",
usename = 1,
utype = "mass",
scale = 45.359237,
default = "lb",
link = "Hundredweight",
},
["short cwt"] = {
name1 = "short hundredweight",
name2 = "short hundredweight",
symbol = "short cwt",
utype = "mass",
scale = 45.359237,
default = "lb kg",
link = "Hundredweight",
},
["short qtr"] = {
name1 = "short quarter",
symbol = "short qtr",
utype = "mass",
scale = 11.33980925,
default = "lb kg",
},
["ST"] = {
symbol = "short ton",
usename = 1,
utype = "mass",
scale = 907.18474,
default = "t",
subdivs = { ["Scwt"] = { 20, default = "t", unit = "-Scwt" } },
},
["shtn"] = {
name1 = "short ton",
symbol = "sh tn",
utype = "mass",
scale = 907.18474,
default = "t",
},
["shton"] = {
symbol = "ton",
usename = 1,
utype = "mass",
scale = 907.18474,
default = "t",
},
["solar mass"] = {
name1 = "solar mass",
name2 = "solar masses",
symbol = "''M''<sub>☉</sub>",
utype = "mass",
scale = 1.98855e30,
default = "kg",
},
["st"] = {
name1 = "stone",
name2 = "stone",
symbol = "st",
utype = "mass",
scale = 6.35029318,
default = "lb kg",
subdivs = { ["lb"] = { 14, default = "kg lb" } },
link = "Stone (unit)",
},
["t"] = {
name1 = "tonne",
name1_us = "metric ton",
symbol = "t",
utype = "mass",
scale = 1000,
default = "LT ST",
},
["tonne"] = {
name1 = "tonne",
name1_us = "metric ton",
symbol = "t",
utype = "mass",
scale = 1000,
default = "shton",
},
["troy pound"] = {
symbol = "troy pound",
usename = 1,
utype = "mass",
scale = 0.3732417216,
default = "lb kg",
link = "Troy weight",
},
["usgalh2o"] = {
name1 = "US gallon of water",
name1_us = "U.S. gallon of water",
name2 = "US gallons of water",
name2_us = "U.S. gallons of water",
symbol = "US gal H<sub>2</sub>O",
utype = "mass",
scale = 3.7776215836051126,
default = "lb kg",
link = "United States customary units#Fluid volume",
},
["viss"] = {
name2 = "viss",
symbol = "viss",
utype = "mass",
scale = 1.632932532,
default = "kg",
link = "Myanmar units of measurement#Mass",
},
["billion tonne"] = {
target = "e9t",
},
["kilogram"] = {
target = "kg",
},
["kilotonne"] = {
target = "kt",
},
["lbs"] = {
target = "lb",
},
["lbt"] = {
target = "troy pound",
},
["lcwt"] = {
target = "Lcwt",
},
["long ton"] = {
target = "LT",
},
["mcg"] = {
target = "μg",
},
["million tonne"] = {
target = "e6t",
},
["scwt"] = {
target = "Scwt",
},
["short ton"] = {
target = "ST",
},
["stone"] = {
target = "st",
},
["thousand tonne"] = {
target = "e3t",
},
["tonnes"] = {
target = "t",
},
["kg/kW"] = {
name1 = "kilogram per kilowatt",
name2 = "kilograms per kilowatt",
symbol = "kg/kW",
utype = "mass per unit power",
scale = 0.001,
default = "lb/hp",
link = "Kilowatt",
},
["lb/hp"] = {
name1 = "pound per horsepower",
name2 = "pounds per horsepower",
symbol = "lb/hp",
utype = "mass per unit power",
scale = 0.00060827738784176115,
default = "kg/kW",
link = "Horsepower",
},
["kg/h"] = {
per = { "kg", "h" },
utype = "mass per unit time",
default = "lb/h",
},
["lb/h"] = {
per = { "lb", "h" },
utype = "mass per unit time",
default = "kg/h",
},
["g-mol/d"] = {
name1 = "gram-mole per day",
name2 = "gram-moles per day",
symbol = "g‑mol/d",
utype = "molar rate",
scale = 1.1574074074074073e-5,
default = "μmol/s",
link = "Mole (unit)",
},
["g-mol/h"] = {
name1 = "gram-mole per hour",
name2 = "gram-moles per hour",
symbol = "g‑mol/h",
utype = "molar rate",
scale = 0.00027777777777777778,
default = "mmol/s",
link = "Mole (unit)",
},
["g-mol/min"] = {
name1 = "gram-mole per minute",
name2 = "gram-moles per minute",
symbol = "g‑mol/min",
utype = "molar rate",
scale = 0.016666666666666666,
default = "g-mol/s",
link = "Mole (unit)",
},
["g-mol/s"] = {
name1 = "gram-mole per second",
name2 = "gram-moles per second",
symbol = "g‑mol/s",
utype = "molar rate",
scale = 1,
default = "lb-mol/min",
link = "Mole (unit)",
},
["gmol/d"] = {
name1 = "gram-mole per day",
name2 = "gram-moles per day",
symbol = "gmol/d",
utype = "molar rate",
scale = 1.1574074074074073e-5,
default = "μmol/s",
link = "Mole (unit)",
},
["gmol/h"] = {
name1 = "gram-mole per hour",
name2 = "gram-moles per hour",
symbol = "gmol/h",
utype = "molar rate",
scale = 0.00027777777777777778,
default = "mmol/s",
link = "Mole (unit)",
},
["gmol/min"] = {
name1 = "gram-mole per minute",
name2 = "gram-moles per minute",
symbol = "gmol/min",
utype = "molar rate",
scale = 0.016666666666666666,
default = "gmol/s",
link = "Mole (unit)",
},
["gmol/s"] = {
name1 = "gram-mole per second",
name2 = "gram-moles per second",
symbol = "gmol/s",
utype = "molar rate",
scale = 1,
default = "lbmol/min",
link = "Mole (unit)",
},
["kmol/d"] = {
name1 = "kilomole per day",
name2 = "kilomoles per day",
symbol = "kmol/d",
utype = "molar rate",
scale = 0.011574074074074073,
default = "mmol/s",
link = "Mole (unit)",
},
["kmol/h"] = {
name1 = "kilomole per hour",
name2 = "kilomoles per hour",
symbol = "kmol/h",
utype = "molar rate",
scale = 0.27777777777777779,
default = "mol/s",
link = "Mole (unit)",
},
["kmol/min"] = {
name1 = "kilomole per minute",
name2 = "kilomoles per minute",
symbol = "kmol/min",
utype = "molar rate",
scale = 16.666666666666668,
default = "mol/s",
link = "Kilomole (unit)",
},
["kmol/s"] = {
name1 = "kilomole per second",
name2 = "kilomoles per second",
symbol = "kmol/s",
utype = "molar rate",
scale = 1000,
default = "lb-mol/s",
link = "Mole (unit)",
},
["lb-mol/d"] = {
name1 = "pound-mole per day",
name2 = "pound-moles per day",
symbol = "lb‑mol/d",
utype = "molar rate",
scale = 0.0052499116898148141,
default = "mmol/s",
link = "Pound-mole",
},
["lb-mol/h"] = {
name1 = "pound-mole per hour",
name2 = "pound-moles per hour",
symbol = "lb‑mol/h",
utype = "molar rate",
scale = 0.12599788055555555,
default = "mol/s",
link = "Pound-mole",
},
["lb-mol/min"] = {
name1 = "pound-mole per minute",
name2 = "pound-moles per minute",
symbol = "lb‑mol/min",
utype = "molar rate",
scale = 7.5598728333333334,
default = "mol/s",
link = "Pound-mole",
},
["lb-mol/s"] = {
name1 = "pound-mole per second",
name2 = "pound-moles per second",
symbol = "lb‑mol/s",
utype = "molar rate",
scale = 453.59237,
default = "kmol/s",
link = "Pound-mole",
},
["lbmol/d"] = {
name1 = "pound-mole per day",
name2 = "pound-moles per day",
symbol = "lbmol/d",
utype = "molar rate",
scale = 0.0052499116898148141,
default = "mmol/s",
link = "Pound-mole",
},
["lbmol/h"] = {
name1 = "pound-mole per hour",
name2 = "pound-moles per hour",
symbol = "lbmol/h",
utype = "molar rate",
scale = 0.12599788055555555,
default = "mol/s",
link = "Pound-mole",
},
["lbmol/min"] = {
name1 = "pound-mole per minute",
name2 = "pound-moles per minute",
symbol = "lbmol/min",
utype = "molar rate",
scale = 7.5598728333333334,
default = "mol/s",
link = "Pound-mole",
},
["lbmol/s"] = {
name1 = "pound-mole per second",
name2 = "pound-moles per second",
symbol = "lbmol/s",
utype = "molar rate",
scale = 453.59237,
default = "kmol/s",
link = "Pound-mole",
},
["mmol/s"] = {
name1 = "millimole per second",
name2 = "millimoles per second",
symbol = "mmol/s",
utype = "molar rate",
scale = 0.001,
default = "lb-mol/d",
link = "Mole (unit)",
},
["mol/d"] = {
name1 = "mole per day",
name2 = "moles per day",
symbol = "mol/d",
utype = "molar rate",
scale = 1.1574074074074073e-5,
default = "μmol/s",
link = "Mole (unit)",
},
["mol/h"] = {
name1 = "mole per hour",
name2 = "moles per hour",
symbol = "mol/h",
utype = "molar rate",
scale = 0.00027777777777777778,
default = "mmol/s",
link = "Mole (unit)",
},
["mol/min"] = {
name1 = "mole per minute",
name2 = "moles per minute",
symbol = "mol/min",
utype = "molar rate",
scale = 0.016666666666666666,
default = "mol/s",
link = "Mole (unit)",
},
["mol/s"] = {
name1 = "mole per second",
name2 = "moles per second",
symbol = "mol/s",
utype = "molar rate",
scale = 1,
default = "lb-mol/min",
link = "Mole (unit)",
},
["μmol/s"] = {
name1 = "micromole per second",
name2 = "micromoles per second",
symbol = "μmol/s",
utype = "molar rate",
scale = 0.000001,
default = "lb-mol/d",
link = "Mole (unit)",
},
["umol/s"] = {
target = "μmol/s",
},
["/acre"] = {
name1 = "per acre",
name2 = "per acre",
symbol = "/acre",
utype = "per unit area",
scale = 0.00024710538146716532,
default = "/ha",
link = "Acre",
},
["/ha"] = {
name1 = "per hectare",
name2 = "per hectare",
symbol = "/ha",
utype = "per unit area",
scale = 100e-6,
default = "/acre",
link = "Hectare",
},
["/sqcm"] = {
name1 = "per square centimetre",
name1_us = "per square centimeter",
name2 = "per square centimetre",
name2_us = "per square centimeter",
symbol = "/cm<sup>2</sup>",
utype = "per unit area",
scale = 1e4,
default = "/sqin",
link = "Square centimetre",
},
["/sqin"] = {
name1 = "per square inch",
name2 = "per square inch",
symbol = "/in<sup>2</sup>",
utype = "per unit area",
scale = 1550.0031000062002,
default = "/sqcm",
link = "Square inch",
},
["/sqkm"] = {
name1 = "per square kilometre",
name1_us = "per square kilometer",
name2 = "per square kilometre",
name2_us = "per square kilometer",
symbol = "/km<sup>2</sup>",
utype = "per unit area",
scale = 1e-6,
default = "/sqmi",
link = "Square kilometre",
},
["/sqmi"] = {
name1 = "per square mile",
name2 = "per square mile",
symbol = "/sq mi",
utype = "per unit area",
scale = 3.8610215854244582e-7,
default = "/sqkm",
link = "Square mile",
},
["PD/acre"] = {
name1 = "inhabitant per acre",
name2 = "inhabitants per acre",
symbol = "/acre",
utype = "per unit area",
scale = 0.00024710538146716532,
default = "PD/ha",
link = "Acre",
},
["PD/ha"] = {
name1 = "inhabitant per hectare",
name2 = "inhabitants per hectare",
symbol = "/ha",
utype = "per unit area",
scale = 100e-6,
default = "PD/acre",
link = "Hectare",
},
["PD/sqkm"] = {
name1 = "inhabitant per square kilometre",
name1_us = "inhabitant per square kilometer",
name2 = "inhabitants per square kilometre",
name2_us = "inhabitants per square kilometer",
symbol = "/km<sup>2</sup>",
utype = "per unit area",
scale = 1e-6,
default = "PD/sqmi",
link = "Square kilometre",
},
["PD/sqmi"] = {
name1 = "inhabitant per square mile",
name2 = "inhabitants per square mile",
symbol = "/sq mi",
utype = "per unit area",
scale = 3.8610215854244582e-7,
default = "PD/sqkm",
link = "Square mile",
},
["/cm2"] = {
target = "/sqcm",
},
["/in2"] = {
target = "/sqin",
},
["/km2"] = {
target = "/sqkm",
},
["pd/acre"] = {
target = "PD/acre",
},
["pd/ha"] = {
target = "PD/ha",
},
["PD/km2"] = {
target = "PD/sqkm",
},
["pd/km2"] = {
target = "PD/sqkm",
},
["PD/km²"] = {
target = "PD/sqkm",
},
["pd/sqkm"] = {
target = "PD/sqkm",
},
["pd/sqmi"] = {
target = "PD/sqmi",
},
["/l"] = {
name1 = "per litre",
name1_us = "per liter",
name2 = "per litre",
name2_us = "per liter",
symbol = "/l",
utype = "per unit volume",
scale = 1000,
default = "/usgal",
link = "Litre",
},
["/L"] = {
name1 = "per litre",
name1_us = "per liter",
name2 = "per litre",
name2_us = "per liter",
symbol = "/L",
utype = "per unit volume",
scale = 1000,
default = "/usgal",
link = "Litre",
},
["/USgal"] = {
name1 = "per gallon",
name2 = "per gallon",
symbol = "/gal",
utype = "per unit volume",
scale = 264.172052,
default = "/L",
link = "US gallon",
customary= 2,
},
["/usgal"] = {
target = "/USgal",
},
["bhp"] = {
name1 = "brake horsepower",
name2 = "brake horsepower",
symbol = "bhp",
utype = "power",
scale = 745.69987158227022,
default = "kW",
link = "Horsepower#Brake horsepower",
},
["Cal/d"] = {
name1 = "large calorie per day",
name2 = "large calories per day",
symbol = "Cal/d",
utype = "power",
scale = 0.048425925925925928,
default = "kJ/d",
link = "Calorie",
},
["Cal/h"] = {
name1 = "large calorie per hour",
name2 = "large calories per hour",
symbol = "Cal/h",
utype = "power",
scale = 1.1622222222222223,
default = "kJ/h",
link = "Calorie",
},
["cal/h"] = {
name1 = "calorie per hour",
name2 = "calories per hour",
symbol = "cal/h",
utype = "power",
scale = 0.0011622222222222223,
default = "W",
link = "Calorie",
},
["CV"] = {
name1 = "metric horsepower",
name2 = "metric horsepower",
symbol = "CV",
utype = "power",
scale = 735.49875,
default = "kW",
},
["hk"] = {
name1 = "metric horsepower",
name2 = "metric horsepower",
symbol = "hk",
utype = "power",
scale = 735.49875,
default = "kW",
},
["hp"] = {
name1 = "horsepower",
name2 = "horsepower",
symbol = "hp",
utype = "power",
scale = 745.69987158227022,
default = "kW",
},
["hp-electric"] = {
name1 = "electric horsepower",
name2 = "electric horsepower",
symbol = "hp",
utype = "power",
scale = 746,
default = "kW",
link = "Horsepower#Electrical horsepower",
},
["hp-electrical"] = {
name1 = "electrical horsepower",
name2 = "electrical horsepower",
symbol = "hp",
utype = "power",
scale = 746,
default = "kW",
link = "Horsepower#Electrical horsepower",
},
["hp-metric"] = {
name1 = "metric horsepower",
name2 = "metric horsepower",
symbol = "hp",
utype = "power",
scale = 735.49875,
default = "kW",
},
["ihp"] = {
name1 = "indicated horsepower",
name2 = "indicated horsepower",
symbol = "ihp",
utype = "power",
scale = 745.69987158227022,
default = "kW",
link = "Horsepower#Indicated horsepower",
},
["kcal/h"] = {
name1 = "kilocalorie per hour",
name2 = "kilocalories per hour",
symbol = "kcal/h",
utype = "power",
scale = 1.1622222222222223,
default = "kW",
link = "Calorie",
},
["kJ/d"] = {
name1 = "kilojoule per day",
name2 = "kilojoules per day",
symbol = "kJ/d",
utype = "power",
scale = 0.011574074074074073,
default = "Cal/d",
link = "Kilojoule",
},
["kJ/h"] = {
name1 = "kilojoule per hour",
name2 = "kilojoules per hour",
symbol = "kJ/h",
utype = "power",
scale = 0.27777777777777779,
default = "W",
link = "Kilojoule",
},
["PS"] = {
name1 = "metric horsepower",
name2 = "metric horsepower",
symbol = "PS",
utype = "power",
scale = 735.49875,
default = "kW",
},
["shp"] = {
name1 = "shaft horsepower",
name2 = "shaft horsepower",
symbol = "shp",
utype = "power",
scale = 745.69987158227022,
default = "kW",
link = "Horsepower#Shaft horsepower",
},
["W"] = {
_name1 = "watt",
_symbol = "W",
utype = "power",
scale = 1,
prefixes = 1,
default = "hp",
link = "Watt",
},
["BTU/h"] = {
per = { "BTU", "h" },
utype = "power",
default = "W",
},
["Btu/h"] = {
per = { "Btu", "h" },
utype = "power",
default = "W",
},
["BHP"] = {
target = "bhp",
},
["btu/h"] = {
target = "BTU/h",
},
["HP"] = {
target = "hp",
},
["Hp"] = {
target = "hp",
},
["hp-mechanical"] = {
target = "hp",
},
["IHP"] = {
target = "ihp",
},
["SHP"] = {
target = "shp",
},
["whp"] = {
target = "hp",
},
["hp/lb"] = {
name1 = "horsepower per pound",
name2 = "horsepower per pound",
symbol = "hp/lb",
utype = "power per unit mass",
scale = 1643.986806,
default = "kW/kg",
link = "Power-to-weight ratio",
},
["hp/LT"] = {
name1 = "horsepower per long ton",
name2 = "horsepower per long ton",
symbol = "hp/LT",
utype = "power per unit mass",
scale = 0.73392268125000004,
default = "kW/t",
link = "Power-to-weight ratio",
},
["hp/ST"] = {
name1 = "horsepower per short ton",
name2 = "horsepower per short ton",
symbol = "hp/ST",
utype = "power per unit mass",
scale = 0.821993403,
default = "kW/t",
link = "Power-to-weight ratio",
},
["hp/t"] = {
name1 = "horsepower per tonne",
name2 = "horsepower per tonne",
symbol = "hp/t",
utype = "power per unit mass",
scale = 0.74569987158227022,
default = "kW/t",
link = "Power-to-weight ratio",
},
["kW/kg"] = {
name1 = "kilowatt per kilogram",
name2 = "kilowatts per kilogram",
symbol = "kW/kg",
utype = "power per unit mass",
scale = 1000,
default = "hp/lb",
link = "Power-to-weight ratio",
},
["kW/t"] = {
name1 = "kilowatt per tonne",
name2 = "kilowatts per tonne",
symbol = "kW/t",
utype = "power per unit mass",
scale = 1,
default = "PS/t",
link = "Power-to-weight ratio",
},
["PS/t"] = {
name1 = "metric horsepower per tonne",
name2 = "metric horsepower per tonne",
symbol = "PS/t",
utype = "power per unit mass",
scale = 0.73549875,
default = "kW/t",
link = "Power-to-weight ratio",
},
["shp/lb"] = {
name1 = "shaft horsepower per pound",
name2 = "shaft horsepower per pound",
symbol = "shp/lb",
utype = "power per unit mass",
scale = 1643.986806,
default = "kW/kg",
link = "Power-to-weight ratio",
},
["hp/tonne"] = {
target = "hp/t",
symbol = "hp/tonne",
default = "kW/tonne",
},
["kW/tonne"] = {
target = "kW/t",
symbol = "kW/tonne",
},
["-lb/in2"] = {
name1 = "pound per square inch",
name2 = "pounds per square inch",
symbol = "lb/in<sup>2</sup>",
utype = "pressure",
scale = 6894.7572931683608,
default = "kPa kgf/cm2",
},
["atm"] = {
name1 = "standard atmosphere",
symbol = "atm",
utype = "pressure",
scale = 101325,
default = "kPa",
link = "Atmosphere (unit)",
},
["Ba"] = {
name1 = "barye",
symbol = "Ba",
utype = "pressure",
scale = 0.1,
default = "Pa",
},
["bar"] = {
symbol = "bar",
utype = "pressure",
scale = 100000,
default = "kPa",
link = "Bar (unit)",
},
["dbar"] = {
name1 = "decibar",
symbol = "dbar",
utype = "pressure",
scale = 10000,
default = "kPa",
link = "Bar (unit)",
},
["inHg"] = {
name1 = "inch of mercury",
name2 = "inches of mercury",
symbol = "inHg",
utype = "pressure",
scale = 3386.388640341,
default = "kPa",
},
["kBa"] = {
name1 = "kilobarye",
symbol = "kBa",
utype = "pressure",
scale = 100,
default = "hPa",
link = "Barye",
},
["kg-f/cm2"] = {
name1 = "kilogram-force per square centimetre",
name1_us = "kilogram-force per square centimeter",
name2 = "kilograms-force per square centimetre",
name2_us = "kilograms-force per square centimeter",
symbol = "kg<sub>f</sub>/cm<sup>2</sup>",
utype = "pressure",
scale = 98066.5,
default = "psi",
link = "Kilogram-force",
},
["kg/cm2"] = {
name1 = "kilogram per square centimetre",
name1_us = "kilogram per square centimeter",
name2 = "kilograms per square centimetre",
name2_us = "kilograms per square centimeter",
symbol = "kg/cm<sup>2</sup>",
utype = "pressure",
scale = 98066.5,
default = "psi",
link = "Kilogram-force",
},
["kgf/cm2"] = {
name1 = "kilogram-force per square centimetre",
name1_us = "kilogram-force per square centimeter",
name2 = "kilograms-force per square centimetre",
name2_us = "kilograms-force per square centimeter",
symbol = "kgf/cm<sup>2</sup>",
utype = "pressure",
scale = 98066.5,
default = "psi",
link = "Kilogram-force",
},
["ksi"] = {
name1 = "kilopound per square inch",
name2 = "kilopounds per square inch",
symbol = "ksi",
utype = "pressure",
scale = 6894757.2931683613,
default = "MPa",
link = "Pound per square inch",
},
["lbf/in2"] = {
name1 = "pound-force per square inch",
name2 = "pounds-force per square inch",
symbol = "lbf/in<sup>2</sup>",
utype = "pressure",
scale = 6894.7572931683608,
default = "kPa kgf/cm2",
},
["mb"] = {
name1 = "millibar",
symbol = "mb",
utype = "pressure",
scale = 100,
default = "hPa",
link = "Bar (unit)",
},
["mbar"] = {
name1 = "millibar",
symbol = "mbar",
utype = "pressure",
scale = 100,
default = "hPa",
link = "Bar (unit)",
},
["mmHg"] = {
name1 = "millimetre of mercury",
name1_us = "millimeter of mercury",
name2 = "millimetres of mercury",
name2_us = "millimeters of mercury",
symbol = "mmHg",
utype = "pressure",
scale = 133.322387415,
default = "kPa",
},
["Pa"] = {
_name1 = "pascal",
_symbol = "Pa",
utype = "pressure",
scale = 1,
prefixes = 1,
default = "psi",
link = "Pascal (unit)",
},
["psf"] = {
name1 = "pound per square foot",
name2 = "pounds per square foot",
symbol = "psf",
utype = "pressure",
scale = 47.880258980335839,
default = "kPa",
link = "Pound per square inch",
},
["psi"] = {
name1 = "pound per square inch",
name2 = "pounds per square inch",
symbol = "psi",
utype = "pressure",
scale = 6894.7572931683608,
default = "kPa",
},
["Torr"] = {
name1 = "torr",
symbol = "Torr",
utype = "pressure",
scale = 133.32236842105263,
default = "kPa",
},
["N/cm2"] = {
per = { "N", "cm2" },
utype = "pressure",
default = "psi",
},
["N/m2"] = {
per = { "N", "m2" },
utype = "pressure",
default = "psi",
},
["g/cm2"] = {
per = { "g", "cm2" },
utype = "pressure",
default = "lb/sqft",
multiplier= 9.80665,
},
["g/m2"] = {
per = { "g", "m2" },
utype = "pressure",
default = "lb/sqft",
multiplier= 9.80665,
},
["kg/ha"] = {
per = { "kg", "ha" },
utype = "pressure",
default = "lb/acre",
multiplier= 9.80665,
},
["kg/m2"] = {
per = { "kg", "m2" },
utype = "pressure",
default = "lb/sqft",
multiplier= 9.80665,
},
["lb/1000sqft"] = {
per = { "lb", "1000sqft" },
utype = "pressure",
default = "g/m2",
multiplier= 9.80665,
},
["lb/acre"] = {
per = { "lb", "acre" },
utype = "pressure",
default = "kg/ha",
multiplier= 9.80665,
},
["lb/sqft"] = {
per = { "lb", "sqft" },
utype = "pressure",
default = "kg/m2",
multiplier= 9.80665,
},
["lb/sqyd"] = {
per = { "lb", "sqyd" },
utype = "pressure",
default = "kg/m2",
multiplier= 9.80665,
},
["LT/acre"] = {
per = { "LT", "acre" },
utype = "pressure",
default = "t/ha",
multiplier= 9.80665,
},
["MT/ha"] = {
per = { "MT", "ha" },
utype = "pressure",
default = "LT/acre ST/acre",
multiplier= 9.80665,
},
["oz/sqft"] = {
per = { "oz", "sqft" },
utype = "pressure",
default = "g/m2",
multiplier= 9.80665,
},
["oz/sqyd"] = {
per = { "oz", "sqyd" },
utype = "pressure",
default = "g/m2",
multiplier= 9.80665,
},
["ST/acre"] = {
per = { "ST", "acre" },
utype = "pressure",
default = "t/ha",
multiplier= 9.80665,
},
["t/ha"] = {
per = { "t", "ha" },
utype = "pressure",
default = "LT/acre ST/acre",
multiplier= 9.80665,
},
["tonne/acre"] = {
per = { "tonne", "acre" },
utype = "pressure",
default = "tonne/ha",
multiplier= 9.80665,
},
["tonne/ha"] = {
per = { "tonne", "ha" },
utype = "pressure",
default = "tonne/acre",
multiplier= 9.80665,
},
["kgfpsqcm"] = {
target = "kgf/cm2",
},
["kgpsqcm"] = {
target = "kg/cm2",
},
["kN/m2"] = {
target = "kPa",
},
["lb/in2"] = {
target = "lbf/in2",
},
["torr"] = {
target = "Torr",
},
["Bq"] = {
_name1 = "becquerel",
_symbol = "Bq",
utype = "radioactivity",
scale = 1,
prefixes = 1,
default = "pCi",
link = "Becquerel",
},
["Ci"] = {
_name1 = "curie",
_symbol = "Ci",
utype = "radioactivity",
scale = 3.7e10,
prefixes = 1,
default = "GBq",
link = "Curie (unit)",
},
["Rd"] = {
_name1 = "rutherford",
_symbol = "Rd",
utype = "radioactivity",
scale = 1e6,
prefixes = 1,
default = "MBq",
link = "Rutherford (unit)",
},
["cm/h"] = {
name1 = "centimetre per hour",
name1_us = "centimeter per hour",
name2 = "centimetres per hour",
name2_us = "centimeters per hour",
symbol = "cm/h",
utype = "speed",
scale = 2.7777777777777775e-6,
default = "in/h",
link = "Metre per second",
},
["cm/s"] = {
name1 = "centimetre per second",
name1_us = "centimeter per second",
name2 = "centimetres per second",
name2_us = "centimeters per second",
symbol = "cm/s",
utype = "speed",
scale = 0.01,
default = "in/s",
link = "Metre per second",
},
["cm/year"] = {
name1 = "centimetre per year",
name1_us = "centimeter per year",
name2 = "centimetres per year",
name2_us = "centimeters per year",
symbol = "cm/year",
utype = "speed",
scale = 3.168873850681143e-10,
default = "in/year",
link = "Orders of magnitude (speed)",
},
["foot/s"] = {
name1 = "foot per second",
name2 = "foot per second",
symbol = "ft/s",
utype = "speed",
scale = 0.3048,
default = "m/s",
},
["ft/min"] = {
name1 = "foot per minute",
name2 = "feet per minute",
symbol = "ft/min",
utype = "speed",
scale = 0.00508,
default = "m/min",
link = "Feet per second",
},
["ft/s"] = {
name1 = "foot per second",
name2 = "feet per second",
symbol = "ft/s",
utype = "speed",
scale = 0.3048,
default = "m/s",
link = "Feet per second",
},
["furlong per fortnight"] = {
name2 = "furlongs per fortnight",
symbol = "furlong per fortnight",
usename = 1,
utype = "speed",
scale = 0.00016630952380952381,
default = "km/h mph",
link = "FFF system",
},
["in/h"] = {
name1 = "inch per hour",
name2 = "inches per hour",
symbol = "in/h",
utype = "speed",
scale = 7.0555555555555559e-6,
default = "cm/h",
link = "Inch",
},
["in/s"] = {
name1 = "inch per second",
name2 = "inches per second",
symbol = "in/s",
utype = "speed",
scale = 0.0254,
default = "cm/s",
link = "Inch",
},
["in/year"] = {
name1 = "inch per year",
name2 = "inches per year",
symbol = "in/year",
utype = "speed",
scale = 8.0489395807301024e-10,
default = "cm/year",
link = "Orders of magnitude (speed)",
},
["isp"] = {
name1 = "second",
symbol = "s",
utype = "speed",
scale = 9.80665,
default = "km/s",
link = "Specific impulse",
},
["km/d"] = {
name1 = "kilometre per day",
name1_us = "kilometer per day",
name2 = "kilometres per day",
name2_us = "kilometers per day",
symbol = "km/d",
utype = "speed",
scale = 1.1574074074074074e-2,
default = "mi/d",
link = "Orders of magnitude (speed)",
},
["km/h"] = {
name1 = "kilometre per hour",
name1_us = "kilometer per hour",
name2 = "kilometres per hour",
name2_us = "kilometers per hour",
symbol = "km/h",
utype = "speed",
scale = 0.27777777777777779,
default = "mph",
link = "Kilometres per hour",
},
["km/s"] = {
name1 = "kilometre per second",
name1_us = "kilometer per second",
name2 = "kilometres per second",
name2_us = "kilometers per second",
symbol = "km/s",
utype = "speed",
scale = 1000,
default = "mi/s",
link = "Metre per second",
},
["kn"] = {
name1 = "knot",
symbol = "kn",
utype = "speed",
scale = 0.51444444444444448,
default = "km/h mph",
link = "Knot (unit)",
},
["kNs/kg"] = {
name2 = "kN‑s/kg",
symbol = "kN‑s/kg",
utype = "speed",
scale = 1000,
default = "isp",
link = "Specific impulse",
},
["m/min"] = {
name1 = "metre per minute",
name1_us = "meter per minute",
name2 = "metres per minute",
name2_us = "meters per minute",
symbol = "m/min",
utype = "speed",
scale = 0.016666666666666666,
default = "ft/min",
link = "Metre per second",
},
["m/s"] = {
name1 = "metre per second",
name1_us = "meter per second",
name2 = "metres per second",
name2_us = "meters per second",
symbol = "m/s",
utype = "speed",
scale = 1,
default = "ft/s",
},
["Mach"] = {
name2 = "Mach",
symbol = "Mach",
utype = "speed",
builtin = "mach",
scale = 0,
iscomplex= true,
default = "km/h mph",
link = "Mach number",
},
["mi/d"] = {
name1 = "mile per day",
name2 = "miles per day",
symbol = "mi/d",
utype = "speed",
scale = 1.8626666666666667e-2,
default = "km/d",
link = "Orders of magnitude (speed)",
},
["mi/s"] = {
name1 = "mile per second",
name2 = "miles per second",
symbol = "mi/s",
utype = "speed",
scale = 1609.344,
default = "km/s",
link = "Mile",
},
["mm/h"] = {
name1 = "millimetre per hour",
name1_us = "millimeter per hour",
name2 = "millimetres per hour",
name2_us = "millimeters per hour",
symbol = "mm/h",
utype = "speed",
scale = 2.7777777777777781e-7,
default = "in/h",
link = "Metre per second",
},
["mph"] = {
name1 = "mile per hour",
name2 = "miles per hour",
symbol = "mph",
utype = "speed",
scale = 0.44704,
default = "km/h",
link = "Miles per hour",
},
["Ns/kg"] = {
name2 = "N‑s/kg",
symbol = "N‑s/kg",
utype = "speed",
scale = 1,
default = "isp",
link = "Specific impulse",
},
["si tsfc"] = {
name2 = "g/(kN⋅s)",
symbol = "g/(kN⋅s)",
utype = "speed",
scale = 9.9999628621379242e-7,
invert = -1,
iscomplex= true,
default = "tsfc",
link = "Thrust specific fuel consumption",
},
["tsfc"] = {
name2 = "lb/(lbf⋅h)",
symbol = "lb/(lbf⋅h)",
utype = "speed",
scale = 2.832545036049801e-5,
invert = -1,
iscomplex= true,
default = "si tsfc",
link = "Thrust specific fuel consumption",
},
["cm/y"] = {
target = "cm/year",
},
["cm/yr"] = {
target = "cm/year",
},
["in/y"] = {
target = "in/year",
},
["in/yr"] = {
target = "in/year",
},
["knot"] = {
target = "kn",
},
["knots"] = {
target = "kn",
},
["kph"] = {
target = "km/h",
},
["mi/h"] = {
target = "mph",
},
["mm/s"] = {
per = { "mm", "s" },
utype = "speed",
default = "in/s",
link = "Metre per second",
},
["C"] = {
name1 = "degree Celsius",
name2 = "degrees Celsius",
symbol = "°C",
usesymbol= 1,
utype = "temperature",
scale = 1,
offset = -273.15,
iscomplex= true,
istemperature= true,
default = "F",
link = "Celsius",
},
["F"] = {
name1 = "degree Fahrenheit",
name2 = "degrees Fahrenheit",
symbol = "°F",
usesymbol= 1,
utype = "temperature",
scale = 0.55555555555555558,
offset = 32-273.15*(9/5),
iscomplex= true,
istemperature= true,
default = "C",
link = "Fahrenheit",
},
["K"] = {
_name1 = "kelvin",
_symbol = "K",
usesymbol= 1,
utype = "temperature",
scale = 1,
offset = 0,
iscomplex= true,
istemperature= true,
prefixes = 1,
default = "C F",
link = "Kelvin",
},
["keVT"] = {
name1 = "kiloelectronvolt",
symbol = "keV",
utype = "temperature",
scale = 11.604505e6,
offset = 0,
iscomplex= true,
default = "MK",
link = "Electronvolt",
},
["R"] = {
name1 = "degree Rankine",
name2 = "degrees Rankine",
symbol = "°R",
usesymbol= 1,
utype = "temperature",
scale = 0.55555555555555558,
offset = 0,
iscomplex= true,
istemperature= true,
default = "K F C",
link = "Rankine scale",
},
["Celsius"] = {
target = "C",
},
["°C"] = {
target = "C",
},
["°F"] = {
target = "F",
},
["°R"] = {
target = "R",
},
["C-change"] = {
name1 = "degree Celsius change",
name2 = "degrees Celsius change",
symbol = "°C",
usesymbol= 1,
utype = "temperature change",
scale = 1,
default = "F-change",
link = "Celsius",
},
["F-change"] = {
name1 = "degree Fahrenheit change",
name2 = "degrees Fahrenheit change",
symbol = "°F",
usesymbol= 1,
utype = "temperature change",
scale = 0.55555555555555558,
default = "C-change",
link = "Fahrenheit",
},
["K-change"] = {
name1 = "kelvin change",
name2 = "kelvins change",
symbol = "K",
usesymbol= 1,
utype = "temperature change",
scale = 1,
default = "F-change",
link = "Kelvin",
},
["°C-change"] = {
target = "C-change",
},
["°F-change"] = {
target = "F-change",
},
["century"] = {
name1 = "century",
name2 = "centuries",
symbol = "ha",
utype = "time",
scale = 3155760000,
default = "Gs",
},
["d"] = {
name1 = "day",
symbol = "d",
utype = "time",
scale = 86400,
default = "ks",
},
["decade"] = {
name1 = "decade",
symbol = "daa",
utype = "time",
scale = 315576000,
default = "Ms",
},
["dog year"] = {
name1 = "dog year",
symbol = "dog yr",
utype = "time",
scale = 220903200,
default = "years",
link = "List of unusual units of measurement#Dog year",
},
["fortnight"] = {
symbol = "fortnight",
usename = 1,
utype = "time",
scale = 1209600,
default = "week",
},
["h"] = {
name1 = "hour",
symbol = "h",
utype = "time",
scale = 3600,
default = "ks",
},
["long billion year"] = {
name1 = "billion years",
name2 = "billion years",
symbol = "Ta",
utype = "time",
scale = 31557600000000000000,
default = "Es",
link = "Annum",
},
["millennium"] = {
name1 = "millennium",
name2 = "millennia",
symbol = "ka",
utype = "time",
scale = 31557600000,
default = "Gs",
},
["milliard year"] = {
name1 = "milliard years",
name2 = "milliard years",
symbol = "Ga",
utype = "time",
scale = 31557600000000000,
default = "Ps",
link = "Annum",
},
["million year"] = {
name1 = "million years",
name2 = "million years",
symbol = "Ma",
utype = "time",
scale = 31557600000000,
default = "Ts",
link = "Annum",
},
["min"] = {
name1 = "minute",
symbol = "min",
utype = "time",
scale = 60,
default = "s",
},
["month"] = {
symbol = "month",
usename = 1,
utype = "time",
scale = 2629800,
default = "Ms",
},
["months"] = {
name1 = "month",
symbol = "mo",
utype = "time",
scale = 2629800,
default = "year",
},
["s"] = {
_name1 = "second",
_symbol = "s",
utype = "time",
scale = 1,
prefixes = 1,
default = "v < 7200 ! min ! h",
link = "Second",
},
["short billion year"] = {
name1 = "billion years",
name2 = "billion years",
symbol = "Ga",
utype = "time",
scale = 31557600000000000,
default = "Ps",
link = "Annum",
},
["short trillion year"] = {
name1 = "trillion years",
name2 = "trillion years",
symbol = "Ta",
utype = "time",
scale = 31557600000000000000,
default = "Es",
link = "Annum",
},
["thousand million year"] = {
name1 = "thousand million years",
name2 = "thousand million years",
symbol = "Ga",
utype = "time",
scale = 31557600000000000,
default = "Ps",
link = "Annum",
},
["wk"] = {
symbol = "week",
usename = 1,
utype = "time",
scale = 604800,
default = "Ms",
},
["year"] = {
name1 = "year",
symbol = "a",
utype = "time",
scale = 31557600,
default = "Ms",
link = "Annum",
},
["years"] = {
name1 = "year",
symbol = "yr",
utype = "time",
scale = 31557600,
default = "Ms",
link = "Annum",
},
["byr"] = {
target = "short billion year",
},
["day"] = {
target = "d",
},
["days"] = {
target = "d",
},
["dog yr"] = {
target = "dog year",
},
["Gyr"] = {
target = "thousand million year",
},
["hour"] = {
target = "h",
},
["hours"] = {
target = "h",
},
["kMyr"] = {
target = "thousand million year",
},
["kmyr"] = {
target = "thousand million year",
},
["kyr"] = {
target = "millennium",
},
["long byr"] = {
target = "long billion year",
},
["minute"] = {
target = "min",
},
["minutes"] = {
target = "min",
},
["mth"] = {
target = "month",
},
["Myr"] = {
target = "million year",
},
["myr"] = {
target = "million year",
},
["sec"] = {
target = "s",
},
["second"] = {
target = "s",
},
["seconds"] = {
target = "s",
},
["tmyr"] = {
target = "thousand million year",
},
["tryr"] = {
target = "short trillion year",
},
["tyr"] = {
target = "millennium",
},
["week"] = {
target = "wk",
},
["weeks"] = {
target = "wk",
},
["yr"] = {
target = "year",
},
["kg.m"] = {
name1 = "kilogram metre",
name1_us = "kilogram meter",
symbol = "kg⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbft",
link = "Kilogram metre (torque)",
},
["kgf.m"] = {
name1 = "kilogram force-metre",
name1_us = "kilogram force-meter",
symbol = "kgf⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbfft",
link = "Kilogram metre (torque)",
},
["kgm"] = {
name1 = "kilogram metre",
name1_us = "kilogram meter",
symbol = "kg⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbfft",
link = "Kilogram metre (torque)",
},
["kpm"] = {
name1 = "kilopond metre",
name1_us = "kilopond meter",
symbol = "kp⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbft",
link = "Kilogram metre (torque)",
},
["lb-fft"] = {
name1 = "pound force-foot",
name2 = "pound force-feet",
symbol = "ft⋅lb<sub>f</sub>",
utype = "torque",
scale = 1.3558179483314004,
default = "Nm",
link = "Pound-foot (torque)",
},
["lb.ft"] = {
name1 = "pound force-foot",
name2 = "pound force-feet",
symbol = "lb⋅ft",
utype = "torque",
scale = 1.3558179483314004,
default = "Nm",
link = "Pound-foot (torque)",
},
["lb.in"] = {
name1 = "pound force-inch",
symbol = "lb⋅in",
utype = "torque",
scale = 0.1129848290276167,
default = "mN.m",
link = "Pound-foot (torque)",
},
["lbfft"] = {
name1 = "pound force-foot",
name2 = "pound force-feet",
symbol = "lbf⋅ft",
utype = "torque",
scale = 1.3558179483314004,
default = "Nm",
link = "Pound-foot (torque)",
},
["lbft"] = {
name1 = "pound-foot",
name2 = "pound-feet",
symbol = "lb⋅ft",
utype = "torque",
scale = 1.3558179483314004,
default = "Nm",
link = "Pound-foot (torque)",
},
["m.kg-f"] = {
name1 = "metre kilogram-force",
name1_us = "meter kilogram-force",
name2 = "metre kilograms-force",
name2_us = "meter kilograms-force",
symbol = "m⋅kg<sub>f</sub>",
utype = "torque",
scale = 9.80665,
default = "Nm lbfft",
link = "Kilogram metre (torque)",
},
["m.kgf"] = {
name1 = "metre kilogram-force",
name1_us = "meter kilogram-force",
name2 = "metre kilograms-force",
name2_us = "meter kilograms-force",
symbol = "m⋅kgf",
utype = "torque",
scale = 9.80665,
default = "Nm lbfft",
link = "Kilogram metre (torque)",
},
["mN.m"] = {
name1 = "millinewton-metre",
name1_us = "millinewton-meter",
symbol = "mN⋅m",
utype = "torque",
scale = 0.001,
default = "lb.in",
link = "Newton-metre",
},
["Nm"] = {
_name1 = "newton-metre",
_name1_us= "newton-meter",
_symbol = "N⋅m",
utype = "torque",
alttype = "energy",
scale = 1,
prefixes = 1,
default = "lbfft",
link = "Newton-metre",
},
["kN/m"] = {
per = { "kN", "-m-stiff" },
utype = "torque",
default = "lbf/in",
},
["lbf/in"] = {
per = { "lbf", "-in-stiff" },
utype = "torque",
default = "kN/m",
},
["lb-f.ft"] = {
target = "lb-fft",
},
["lbf.ft"] = {
target = "lbfft",
},
["lbf·ft"] = {
target = "lbfft",
},
["lb·ft"] = {
target = "lb.ft",
},
["mkg-f"] = {
target = "m.kg-f",
},
["mkgf"] = {
target = "m.kgf",
},
["N.m"] = {
target = "Nm",
},
["N·m"] = {
target = "Nm",
},
["ton-mile"] = {
symbol = "ton-mile",
usename = 1,
utype = "transportation",
scale = 1.4599723182105602,
default = "tkm",
},
["tkm"] = {
name1 = "tonne-kilometre",
name1_us = "tonne-kilometer",
symbol = "tkm",
utype = "transportation",
scale = 1,
default = "ton-mile",
},
["-12USoz(mL)serve"] = {
name1_us = "12 U.S. fl oz (355 mL) serving",
symbol = "12 US fl oz (355 mL) serving",
sym_us = "12 U.S. fl oz (355 mL) serving",
utype = "volume",
scale = 0.00035488235475000004,
default = "mL",
link = "Beverage can#Standard sizes",
},
["-12USoz(ml)serve"] = {
name1_us = "12 U.S. fl oz (355 ml) serving",
symbol = "12 US fl oz (355 ml) serving",
sym_us = "12 U.S. fl oz (355 ml) serving",
utype = "volume",
scale = 0.00035488235475000004,
default = "ml",
link = "Beverage can#Standard sizes",
},
["-12USozserve"] = {
name1_us = "12 U.S. fl oz serving",
symbol = "12 US fl oz serving",
sym_us = "12 U.S. fl oz serving",
utype = "volume",
scale = 0.00035488235475000004,
default = "mL",
link = "Beverage can#Standard sizes",
},
["acre-foot"] = {
name1 = "acre-foot",
name2 = "acre-foot",
symbol = "acre⋅ft",
utype = "volume",
scale = 1233.48183754752,
default = "m3",
},
["acre-ft"] = {
name1 = "acre-foot",
name2 = "acre-feet",
symbol = "acre⋅ft",
utype = "volume",
scale = 1233.48183754752,
default = "m3",
},
["AUtbsp"] = {
name1 = "Australian tablespoon",
symbol = "AU tbsp",
utype = "volume",
scale = 0.000020,
default = "ml",
},
["Bcuft"] = {
name1 = "billion cubic foot",
name2 = "billion cubic feet",
symbol = "billion cu ft",
utype = "volume",
scale = 28316846.592,
default = "Gl",
link = "Cubic foot",
},
["bdft"] = {
name1 = "board foot",
name2 = "board feet",
symbol = "bd ft",
utype = "volume",
scale = 0.0023597372167,
default = "m3",
},
["board feet"] = {
name2 = "board feet",
symbol = "board foot",
usename = 1,
utype = "volume",
scale = 0.0023597372167,
default = "m3",
},
["board foot"] = {
name2 = "board foot",
symbol = "board foot",
usename = 1,
utype = "volume",
scale = 0.0023597372167,
default = "m3",
},
["cc"] = {
name1 = "cubic centimetre",
name1_us = "cubic centimeter",
symbol = "cc",
utype = "volume",
scale = 0.000001,
default = "cuin",
},
["CID"] = {
name1 = "cubic inch",
name2 = "cubic inches",
symbol = "cu in",
utype = "volume",
scale = 0.000016387064,
default = "cc",
link = "Cubic inch#Engine displacement",
},
["cord"] = {
symbol = "cord",
utype = "volume",
scale = 3.624556363776,
default = "m3",
link = "Cord (unit)",
},
["cufoot"] = {
name1 = "cubic foot",
name2 = "cubic foot",
symbol = "cu ft",
utype = "volume",
scale = 0.028316846592,
default = "m3",
},
["cuft"] = {
name1 = "cubic foot",
name2 = "cubic feet",
symbol = "cu ft",
utype = "volume",
scale = 0.028316846592,
default = "m3",
},
["cuin"] = {
name1 = "cubic inch",
name2 = "cubic inches",
symbol = "cu in",
utype = "volume",
scale = 0.000016387064,
default = "cm3",
},
["cumi"] = {
name1 = "cubic mile",
symbol = "cu mi",
utype = "volume",
scale = 4168181825.440579584,
default = "km3",
},
["cuyd"] = {
name1 = "cubic yard",
symbol = "cu yd",
utype = "volume",
scale = 0.764554857984,
default = "m3",
},
["firkin"] = {
symbol = "firkin",
usename = 1,
utype = "volume",
scale = 0.04091481,
default = "L impgal USgal",
link = "Firkin (unit)",
},
["foot3"] = {
target = "cufoot",
},
["Goilbbl"] = {
name1 = "billion barrels",
name2 = "billion barrels",
symbol = "Gbbl",
utype = "volume",
scale = 158987294.928,
default = "v * 1.58987294928 < 10 ! e6 ! e9 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["gr water"] = {
name1 = "grains water",
name2 = "grains water",
symbol = "gr H<sub>2</sub>O",
utype = "volume",
scale = 0.00000006479891,
default = "cm3",
link = "Grain (unit)",
},
["grt"] = {
name1 = "gross register ton",
symbol = "grt",
utype = "volume",
scale = 2.8316846592,
default = "m3",
link = "Gross register tonnage",
},
["impbbl"] = {
name1 = "imperial barrel",
symbol = "imp bbl",
utype = "volume",
scale = 0.16365924,
default = "L impgal USgal",
link = "Barrel (unit)",
},
["impbsh"] = {
name1 = "imperial bushel",
symbol = "imp bsh",
utype = "volume",
scale = 0.03636872,
default = "L impgal USdrygal",
},
["impbu"] = {
name1 = "imperial bushel",
symbol = "imp bu",
utype = "volume",
scale = 0.03636872,
default = "m3",
},
["impgal"] = {
name1 = "imperial gallon",
symbol = "imp gal",
utype = "volume",
scale = 0.00454609,
default = "L USgal",
},
["impgi"] = {
name1 = "gill",
symbol = "gi",
utype = "volume",
scale = 0.0001420653125,
default = "ml USoz",
link = "Gill (unit)",
},
["impkenning"] = {
name1 = "imperial kenning",
symbol = "kenning",
utype = "volume",
scale = 0.01818436,
default = "L USdrygal",
link = "Kenning (unit)",
},
["impoz"] = {
name1 = "imperial fluid ounce",
symbol = "imp fl oz",
utype = "volume",
scale = 0.0000284130625,
default = "ml USoz",
},
["imppk"] = {
name1 = "imperial peck",
symbol = "pk",
utype = "volume",
scale = 0.00909218,
default = "L USdrygal",
link = "Peck",
},
["imppt"] = {
name1 = "imperial pint",
symbol = "imp pt",
utype = "volume",
scale = 0.00056826125,
default = "L",
},
["impqt"] = {
name1 = "imperial quart",
symbol = "imp qt",
utype = "volume",
scale = 0.0011365225,
default = "ml USoz",
customary= 3,
},
["kilderkin"] = {
symbol = "kilderkin",
usename = 1,
utype = "volume",
scale = 0.08182962,
default = "L impgal USgal",
},
["koilbbl"] = {
name1 = "thousand barrels",
name2 = "thousand barrels",
symbol = "kbbl",
utype = "volume",
scale = 158.987294928,
default = "v * 1.58987294928 < 10 ! ! e3 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["L"] = {
_name1 = "litre",
_name1_us= "liter",
_symbol = "L",
utype = "volume",
scale = 0.001,
prefixes = 1,
default = "impgal USgal",
link = "Litre",
},
["l"] = {
_name1 = "litre",
_name1_us= "liter",
_symbol = "l",
utype = "volume",
scale = 0.001,
prefixes = 1,
default = "impgal USgal",
link = "Litre",
},
["ll"] = {
name1 = "litre",
name1_us = "liter",
symbol = "l",
utype = "volume",
scale = 0.001,
default = "impgal USgal",
},
["m3"] = {
_name1 = "cubic metre",
_name1_us= "cubic meter",
_symbol = "m<sup>3</sup>",
prefix_position= 7,
utype = "volume",
scale = 1,
prefixes = 3,
default = "cuft",
link = "Cubic metre",
},
["Mbbl"] = {
name1 = "thousand barrels",
name2 = "thousand barrels",
symbol = "Mbbl",
utype = "volume",
scale = 158.987294928,
default = "v * 1.58987294928 < 10 ! e3 ! ! m3",
link = "Barrel (unit)#Oil barrel",
},
["MMoilbbl"] = {
name1 = "million barrels",
name2 = "million barrels",
symbol = "MMbbl",
utype = "volume",
scale = 158987.294928,
default = "v * 1.58987294928 < 10 ! e3 ! e6 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["Moilbbl"] = {
name1 = "million barrels",
name2 = "million barrels",
symbol = "Mbbl",
utype = "volume",
scale = 158987.294928,
default = "v * 1.58987294928 < 10 ! e3 ! e6 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["MTON"] = {
name1 = "measurement ton",
symbol = "MTON",
utype = "volume",
scale = 1.13267386368,
default = "m3",
},
["MUSgal"] = {
name1 = "million US gallons",
name1_us = "million U.S. gallons",
name2 = "million US gallons",
name2_us = "million U.S. gallons",
symbol = "million US gal",
sym_us = "million U.S. gal",
utype = "volume",
scale = 3785.411784,
default = "Ml",
link = "US gallon",
},
["oilbbl"] = {
name1 = "barrel",
symbol = "bbl",
utype = "volume",
scale = 0.158987294928,
default = "m3",
link = "Barrel (unit)#Oil barrel",
},
["stere"] = {
symbol = "stere",
usename = 1,
utype = "volume",
scale = 1,
default = "cuft",
},
["Toilbbl"] = {
name1 = "trillion barrels",
name2 = "trillion barrels",
symbol = "Tbbl",
utype = "volume",
scale = 158987294928,
default = "v * 1.58987294928 < 10 ! e9 ! e12 ! m3",
link = "Barrel (unit)#Oil barrel",
},
["USbbl"] = {
name1 = "US barrel",
name1_us = "U.S. barrel",
symbol = "US bbl",
sym_us = "U.S. bbl",
utype = "volume",
scale = 0.119240471196,
default = "L USgal impgal",
link = "Barrel (unit)",
},
["USbeerbbl"] = {
name1 = "US beer barrel",
name1_us = "U.S. beer barrel",
symbol = "US bbl",
sym_us = "U.S. bbl",
utype = "volume",
scale = 0.117347765304,
default = "L USgal impgal",
link = "Barrel (unit)",
},
["USbsh"] = {
name1 = "US bushel",
name1_us = "U.S. bushel",
symbol = "US bsh",
sym_us = "U.S. bsh",
utype = "volume",
scale = 0.03523907016688,
default = "L USdrygal impgal",
link = "Bushel",
},
["USbu"] = {
name1 = "US bushel",
name1_us = "U.S. bushel",
symbol = "US bu",
sym_us = "U.S. bu",
utype = "volume",
scale = 0.03523907016688,
default = "L USdrygal impgal",
link = "Bushel",
},
["USdrybbl"] = {
name1 = "US dry barrel",
name1_us = "U.S. dry barrel",
symbol = "US dry bbl",
sym_us = "U.S. dry bbl",
utype = "volume",
scale = 0.11562819898508,
default = "m3",
link = "Barrel (unit)",
},
["USdrygal"] = {
name1 = "US dry gallon",
name1_us = "U.S. dry gallon",
symbol = "US dry gal",
sym_us = "U.S. dry gal",
utype = "volume",
scale = 0.00440488377086,
default = "L",
link = "Gallon",
},
["USdrypt"] = {
name1 = "US dry pint",
name1_us = "U.S. dry pint",
symbol = "US dry pt",
sym_us = "U.S. dry pt",
utype = "volume",
scale = 0.0005506104713575,
default = "ml",
link = "Pint",
},
["USdryqt"] = {
name1 = "US dry quart",
name1_us = "U.S. dry quart",
symbol = "US dry qt",
sym_us = "U.S. dry qt",
utype = "volume",
scale = 0.001101220942715,
default = "ml",
link = "Quart",
},
["USflgal"] = {
name1 = "US gallon",
name1_us = "U.S. gallon",
symbol = "US fl gal",
sym_us = "U.S. fl gal",
utype = "volume",
scale = 0.003785411784,
default = "L impgal",
link = "Gallon",
},
["USgal"] = {
name1 = "US gallon",
name1_us = "U.S. gallon",
symbol = "US gal",
sym_us = "U.S. gal",
utype = "volume",
scale = 0.003785411784,
default = "L impgal",
},
["USgi"] = {
name1 = "gill",
symbol = "gi",
utype = "volume",
scale = 0.0001182941183,
default = "ml impoz",
link = "Gill (unit)",
},
["USkenning"] = {
name1 = "US kenning",
name1_us = "U.S. kenning",
symbol = "US kenning",
sym_us = "U.S. kenning",
utype = "volume",
scale = 0.01761953508344,
default = "L impgal",
link = "Kenning (unit)",
},
["USmin"] = {
name1 = "US minim",
name1_us = "U.S. minim",
symbol = "US min",
sym_us = "U.S. min",
utype = "volume",
scale = 0.000000061611519921875,
default = "ml",
link = "Minim (unit)",
},
["USoz"] = {
name1 = "US fluid ounce",
name1_us = "U.S. fluid ounce",
symbol = "US fl oz",
sym_us = "U.S. fl oz",
utype = "volume",
scale = 0.0000295735295625,
default = "ml",
},
["USpk"] = {
name1 = "US peck",
name1_us = "U.S. peck",
symbol = "US pk",
sym_us = "U.S. pk",
utype = "volume",
scale = 0.00880976754172,
default = "L impgal",
link = "Peck",
},
["USpt"] = {
name1 = "US pint",
name1_us = "U.S. pint",
symbol = "US pt",
sym_us = "U.S. pt",
utype = "volume",
scale = 0.000473176473,
default = "L imppt",
link = "Pint",
},
["USqt"] = {
name1 = "US quart",
name1_us = "U.S. quart",
symbol = "US qt",
sym_us = "U.S. qt",
utype = "volume",
scale = 0.000946352946,
default = "ml",
link = "Quart",
customary= 1,
},
["USquart"] = {
name1 = "US quart",
name1_us = "U.S. quart",
symbol = "US qt",
sym_us = "U.S. qt",
utype = "volume",
scale = 0.000946352946,
default = "ml impoz",
link = "Quart",
},
["UStbsp"] = {
name1 = "US tablespoon",
name1_us = "U.S. tablespoon",
symbol = "US tbsp",
sym_us = "U.S. tbsp",
utype = "volume",
scale = 1.4786764781250001e-5,
default = "ml",
},
["winecase"] = {
symbol = "case",
usename = 1,
utype = "volume",
scale = 0.009,
default = "L",
link = "Case (goods)",
},
["*U.S.drygal"] = {
target = "USdrygal",
sp_us = true,
customary= 2,
},
["*U.S.gal"] = {
target = "USgal",
sp_us = true,
customary= 2,
},
["+USdrygal"] = {
target = "USdrygal",
customary= 1,
},
["+usfloz"] = {
target = "USoz",
link = "Fluid ounce",
customary= 1,
},
["+USgal"] = {
target = "USgal",
customary= 1,
},
["+USoz"] = {
target = "USoz",
customary= 1,
},
["@impgal"] = {
target = "impgal",
link = "Gallon",
customary= 3,
},
["acre feet"] = {
target = "acre-ft",
},
["acre foot"] = {
target = "acre-foot",
},
["acre ft"] = {
target = "acre-ft",
},
["acre-feet"] = {
target = "acre-ft",
},
["acre.foot"] = {
target = "acre-foot",
},
["acre.ft"] = {
target = "acre-ft",
},
["acre·ft"] = {
target = "acre-ft",
},
["bushels"] = {
target = "USbsh",
},
["cid"] = {
target = "CID",
},
["ft3"] = {
target = "cuft",
},
["gal"] = {
target = "USgal",
},
["gallon"] = {
shouldbe = "Use %{USgal%} for US gallons or %{impgal%} for imperial gallons (not %{gallon%})",
},
["gallons"] = {
shouldbe = "Use %{USgal%} for US gallons or %{impgal%} for imperial gallons (not %{gallons%})",
},
["Gcuft"] = {
target = "e9cuft",
},
["impfloz"] = {
target = "impoz",
},
["Impgal"] = {
target = "impgal",
},
["in3"] = {
target = "cuin",
symbol = "in<sup>3</sup>",
},
["hm³"] = {
target = "hm3",
},
["kcuft"] = {
target = "e3cuft",
},
["kcum"] = {
target = "e3m3",
},
["km³"] = {
target = "km3",
},
["liter"] = {
target = "L",
sp_us = true,
},
["liters"] = {
target = "L",
sp_us = true,
},
["litre"] = {
target = "L",
},
["litres"] = {
target = "L",
},
["Mcuft"] = {
target = "e6cuft",
},
["Mcum"] = {
target = "e6m3",
},
["Mft3"] = {
target = "e6cuft",
},
["mi3"] = {
target = "cumi",
},
["m³"] = {
target = "m3",
},
["Pcuft"] = {
target = "e15cuft",
},
["pt"] = {
shouldbe = "Use %{USpt%} for US pints or %{imppt%} for imperial pints (not %{pt%})",
},
["qt"] = {
shouldbe = "Use %{USqt%} for US quarts or %{impqt%} for imperial quarts (not %{qt%})",
},
["Tcuft"] = {
target = "e12cuft",
},
["Tft3"] = {
target = "e12cuft",
},
["U.S.bbl"] = {
target = "USbbl",
sp_us = true,
default = "L U.S.gal impgal",
},
["U.S.beerbbl"] = {
target = "USbeerbbl",
sp_us = true,
default = "L U.S.gal impgal",
},
["U.S.bsh"] = {
target = "USbsh",
sp_us = true,
default = "L U.S.drygal impgal",
},
["U.S.bu"] = {
target = "USbu",
sp_us = true,
default = "L U.S.drygal impgal",
},
["U.S.drybbl"] = {
target = "USdrybbl",
sp_us = true,
},
["U.S.drygal"] = {
target = "USdrygal",
sp_us = true,
},
["U.S.drypt"] = {
target = "USdrypt",
sp_us = true,
},
["U.S.dryqt"] = {
target = "USdryqt",
sp_us = true,
},
["U.S.flgal"] = {
target = "USflgal",
sp_us = true,
},
["U.S.floz"] = {
target = "USoz",
sp_us = true,
},
["U.S.gal"] = {
target = "USgal",
sp_us = true,
link = "U.S. gallon",
},
["u.s.gal"] = {
target = "USgal",
sp_us = true,
link = "U.S. gallon",
},
["U.S.gi"] = {
target = "USgi",
sp_us = true,
},
["U.S.kenning"] = {
target = "USkenning",
sp_us = true,
},
["U.S.oz"] = {
target = "USoz",
sp_us = true,
},
["U.S.pk"] = {
target = "USpk",
sp_us = true,
},
["U.S.pt"] = {
target = "USpt",
sp_us = true,
},
["U.S.qt"] = {
target = "USqt",
sp_us = true,
default = "L impqt",
customary= 2,
},
["usbbl"] = {
target = "USbbl",
},
["usbeerbbl"] = {
target = "USbeerbbl",
},
["usbsh"] = {
target = "USbsh",
},
["usbu"] = {
target = "USbu",
},
["usdrybbl"] = {
target = "USdrybbl",
},
["usdrygal"] = {
target = "USdrygal",
},
["usdrypt"] = {
target = "USdrypt",
},
["usdryqt"] = {
target = "USdryqt",
},
["USfloz"] = {
target = "USoz",
},
["usfloz"] = {
target = "USoz",
},
["USGAL"] = {
target = "USgal",
},
["usgal"] = {
target = "USgal",
},
["usgi"] = {
target = "USgi",
},
["uskenning"] = {
target = "USkenning",
},
["usoz"] = {
target = "USoz",
},
["uspk"] = {
target = "USpk",
},
["uspt"] = {
target = "USpt",
},
["usqt"] = {
target = "USqt",
},
["yd3"] = {
target = "cuyd",
},
["cuft/sqmi"] = {
per = { "cuft", "sqmi" },
utype = "volume per unit area",
default = "m3/km2",
},
["m3/ha"] = {
name1 = "cubic metre per hectare",
name1_us = "cubic meter per hectare",
name2 = "cubic metres per hectare",
name2_us = "cubic meters per hectare",
symbol = "m<sup>3</sup>/ha",
utype = "volume per unit area",
scale = 0.0001,
default = "USbu/acre",
link = "Hectare",
},
["m3/km2"] = {
per = { "m3", "km2" },
utype = "volume per unit area",
default = "cuft/sqmi",
},
["U.S.gal/acre"] = {
per = { "U.S.gal", "acre" },
utype = "volume per unit area",
default = "m3/km2",
},
["USbu/acre"] = {
name2 = "US bushels per acre",
symbol = "US bushel per acre",
usename = 1,
utype = "volume per unit area",
scale = 8.7077638761350888e-6,
default = "m3/ha",
link = "Bushel",
},
["USgal/acre"] = {
per = { "USgal", "acre" },
utype = "volume per unit area",
default = "m3/km2",
},
["cuyd/mi"] = {
per = { "cuyd", "mi" },
utype = "volume per unit length",
default = "m3/km",
},
["m3/km"] = {
per = { "m3", "km" },
utype = "volume per unit length",
default = "cuyd/mi",
},
["mich"] = {
combination= { "ch", "mi" },
multiple = { 80 },
utype = "length",
},
["michlk"] = {
combination= { "chlk", "mi" },
multiple = { 80 },
utype = "length",
},
["michainlk"] = {
combination= { "chainlk", "mi" },
multiple = { 80 },
utype = "length",
},
["miyd"] = {
combination= { "yd", "mi" },
multiple = { 1760 },
utype = "length",
},
["miydftin"] = {
combination= { "in", "ft", "yd", "mi" },
multiple = { 12, 3, 1760 },
utype = "length",
},
["mift"] = {
combination= { "ft", "mi" },
multiple = { 5280 },
utype = "length",
},
["ydftin"] = {
combination= { "in", "ft", "yd" },
multiple = { 12, 3 },
utype = "length",
},
["ydft"] = {
combination= { "ft", "yd" },
multiple = { 3 },
utype = "length",
},
["ftin"] = {
combination= { "in", "ft" },
multiple = { 12 },
utype = "length",
},
["footin"] = {
combination= { "in", "foot" },
multiple = { 12 },
utype = "length",
},
["handin"] = {
combination= { "in", "hand" },
multiple = { 4 },
utype = "length",
},
["lboz"] = {
combination= { "oz", "lb" },
multiple = { 16 },
utype = "mass",
},
["stlb"] = {
combination= { "lb", "st" },
multiple = { 14 },
utype = "mass",
},
["stlboz"] = {
combination= { "oz", "lb", "st" },
multiple = { 16, 14 },
utype = "mass",
},
["st and lb"] = {
combination= { "lb", "st" },
multiple = { 14 },
utype = "mass",
},
["GN LTf"] = {
combination= { "GN", "-LTf" },
utype = "force",
},
["GN LTf STf"] = {
combination= { "GN", "-LTf", "-STf" },
utype = "force",
},
["GN STf"] = {
combination= { "GN", "-STf" },
utype = "force",
},
["GN STf LTf"] = {
combination= { "GN", "-STf", "-LTf" },
utype = "force",
},
["kN LTf"] = {
combination= { "kN", "-LTf" },
utype = "force",
},
["kN LTf STf"] = {
combination= { "kN", "-LTf", "-STf" },
utype = "force",
},
["kN STf"] = {
combination= { "kN", "-STf" },
utype = "force",
},
["kN STf LTf"] = {
combination= { "kN", "-STf", "-LTf" },
utype = "force",
},
["LTf STf"] = {
combination= { "-LTf", "-STf" },
utype = "force",
},
["MN LTf"] = {
combination= { "MN", "-LTf" },
utype = "force",
},
["MN LTf STf"] = {
combination= { "MN", "-LTf", "-STf" },
utype = "force",
},
["MN STf"] = {
combination= { "MN", "-STf" },
utype = "force",
},
["MN STf LTf"] = {
combination= { "MN", "-STf", "-LTf" },
utype = "force",
},
["STf LTf"] = {
combination= { "-STf", "-LTf" },
utype = "force",
},
["L/100 km mpgimp"] = {
combination= { "L/100 km", "mpgimp" },
utype = "fuel efficiency",
},
["l/100 km mpgimp"] = {
combination= { "l/100 km", "mpgimp" },
utype = "fuel efficiency",
},
["L/100 km mpgUS"] = {
combination= { "L/100 km", "mpgus" },
utype = "fuel efficiency",
},
["L/100 km mpgus"] = {
combination= { "L/100 km", "mpgus" },
utype = "fuel efficiency",
},
["l/100 km mpgus"] = {
combination= { "l/100 km", "mpgus" },
utype = "fuel efficiency",
},
["mpgimp L/100 km"] = {
combination= { "mpgimp", "L/100 km" },
utype = "fuel efficiency",
},
["LT ST t"] = {
combination= { "lt", "-ST", "t" },
utype = "mass",
},
["LT t ST"] = {
combination= { "lt", "t", "-ST" },
utype = "mass",
},
["ST LT t"] = {
combination= { "-ST", "lt", "t" },
utype = "mass",
},
["ST t LT"] = {
combination= { "-ST", "t", "lt" },
utype = "mass",
},
["t LT ST"] = {
combination= { "t", "lt", "-ST" },
utype = "mass",
},
["ton"] = {
combination= { "LT", "ST" },
utype = "mass",
},
["kPa kg/cm2"] = {
combination= { "kPa", "kgf/cm2" },
utype = "pressure",
},
["kPa lb/in2"] = {
combination= { "kPa", "-lb/in2" },
utype = "pressure",
},
["floz"] = {
combination= { "impoz", "USoz" },
utype = "volume",
},
}
---------------------------------------------------------------------------
-- Do not change the data in this table because it is created by running --
-- a script that reads the wikitext from a wiki page (see note above). --
---------------------------------------------------------------------------
local default_exceptions = {
-- Prefixed units with a default different from that of the base unit.
-- Each key item is a prefixed symbol (unitcode for engineering notation).
["cm<sup>2</sup>"] = "sqin",
["dm<sup>2</sup>"] = "sqin",
["e3acre"] = "km2",
["e3m2"] = "e6sqft",
["e6acre"] = "km2",
["e6ha"] = "e6acre",
["e6km2"] = "e6sqmi",
["e6m2"] = "e6sqft",
["e6sqft"] = "v * 9.290304 < 100 ! e3 ! e6 ! m2",
["e6sqmi"] = "e6km2",
["hm<sup>2</sup>"] = "acre",
["km<sup>2</sup>"] = "sqmi",
["mm<sup>2</sup>"] = "sqin",
["aJ"] = "eV",
["e3BTU"] = "MJ",
["e6BTU"] = "GJ",
["EJ"] = "kWh",
["fJ"] = "keV",
["GJ"] = "kWh",
["MJ"] = "kWh",
["PJ"] = "kWh",
["pJ"] = "MeV",
["TJ"] = "kWh",
["YJ"] = "kWh",
["yJ"] = "μeV",
["ZJ"] = "kWh",
["zJ"] = "meV",
["e12cuft/a"] = "v * 2.8316846592 < 100 ! e9 ! e12 ! m3/a",
["e12cuft/d"] = "v * 2.8316846592 < 100 ! e9 ! e12 ! m3/d",
["e12m3/a"] = "Tcuft/a",
["e12m3/d"] = "Tcuft/d",
["e3cuft/a"] = "v * 2.8316846592 < 100 ! ! e3 ! m3/a",
["e3cuft/d"] = "v * 2.8316846592 < 100 ! ! e3 ! m3/d",
["e3cuft/s"] = "v * 2.8316846592 < 100 ! ! e3 ! m3/s",
["e3m3/a"] = "v < 28.316846592 ! k ! M ! cuft/a",
["e3m3/d"] = "v < 28.316846592 ! k ! M ! cuft/d",
["e3m3/s"] = "v < 28.316846592 ! k ! M ! cuft/s",
["e3USgal/a"] = "v * 3.785411784 < 1000 ! ! e3 ! m3/a",
["e6cuft/a"] = "v * 2.8316846592 < 100 ! e3 ! e6 ! m3/a",
["e6cuft/d"] = "v * 2.8316846592 < 100 ! e3 ! e6 ! m3/d",
["e6cuft/s"] = "v * 2.8316846592 < 100 ! e3 ! e6 ! m3/s",
["e6m3/a"] = "v < 28.316846592 ! M ! G ! cuft/a",
["e6m3/d"] = "v < 28.316846592 ! M ! G ! cuft/d",
["e6m3/s"] = "v < 28.316846592 ! e6 ! e9 ! cuft/s",
["e6USgal/a"] = "v * 3.785411784 < 1000 ! e3 ! e6 ! m3/a",
["e9cuft/a"] = "m3/a",
["e9cuft/d"] = "v * 2.8316846592 < 100 ! e6 ! e9 ! m3/d",
["e9m3/a"] = "v < 28.316846592 ! G ! T ! cuft/a",
["e9m3/d"] = "v < 28.316846592 ! G ! T ! cuft/d",
["e9m3/s"] = "v < 28.316846592 ! e9 ! e12 ! cuft/s",
["e9USgal/a"] = "v * 3.785411784 < 1000 ! e6 ! e9 ! m3/a",
["e9USgal/s"] = "v * 3.785411784 < 1000 ! e6 ! e9 ! m3/s",
["nN"] = "gr-f",
["μN"] = "gr-f",
["mN"] = "oz-f",
["am"] = "in",
["cm"] = "in",
["dam"] = "ft",
["dm"] = "in",
["e12km"] = "e12mi",
["e12mi"] = "e12km",
["e3AU"] = "ly",
["e3km"] = "e3mi",
["e3mi"] = "e3km",
["e6km"] = "e6mi",
["e6mi"] = "e6km",
["e9km"] = "AU",
["e9mi"] = "e9km",
["Em"] = "mi",
["fm"] = "in",
["Gm"] = "mi",
["hm"] = "ft",
["km"] = "mi",
["mm"] = "in",
["Mm"] = "mi",
["nm"] = "in",
["Pm"] = "mi",
["pm"] = "in",
["Tm"] = "mi",
["Ym"] = "mi",
["ym"] = "in",
["Zm"] = "mi",
["zm"] = "in",
["μm"] = "in",
["e12lb"] = "v * 4.5359237 < 10 ! Mt ! Gt",
["e3lb"] = "v * 4.5359237 < 10 ! kg ! t",
["e3ozt"] = "v * 0.311034768 < 10 ! kg ! t",
["e3t"] = "LT ST",
["e6carat"] = "t",
["e6lb"] = "v * 4.5359237 < 10 ! t ! kilotonne",
["e6ozt"] = "lb kg",
["e6ST"] = "Mt",
["e6t"] = "LT ST",
["e9lb"] = "v * 4.5359237 < 10 ! kilotonne ! Mt",
["e9t"] = "LT ST",
["Gg"] = "lb",
["kg"] = "lb",
["mg"] = "gr",
["Mg"] = "LT ST",
["ng"] = "gr",
["μg"] = "gr",
["mBq"] = "fCi",
["kBq"] = "nCi",
["MBq"] = "μCi",
["GBq"] = "mCi",
["TBq"] = "Ci",
["PBq"] = "kCi",
["EBq"] = "kCi",
["fCi"] = "mBq",
["pCi"] = "Bq",
["nCi"] = "Bq",
["μCi"] = "kBq",
["mCi"] = "MBq",
["kCi"] = "TBq",
["MCi"] = "PBq",
["ns"] = "μs",
["μs"] = "ms",
["ms"] = "s",
["ks"] = "h",
["Ms"] = "week",
["Gs"] = "decade",
["Ts"] = "millennium",
["Ps"] = "million year",
["Es"] = "thousand million year",
["MK"] = "keVT",
["cL"] = "impoz usoz",
["cl"] = "impoz usoz",
["cm<sup>3</sup>"] = "cuin",
["dL"] = "impoz usoz",
["dl"] = "impoz usoz",
["mm<sup>3</sup>"] = "cuin",
["dm<sup>3</sup>"] = "cuin",
["e12cuft"] = "v * 2.8316846592 < 100 ! e9 ! e12 ! m3",
["e12impgal"] = "v * 4.54609 < 1000 ! T ! P ! l",
["e12m3"] = "v < 28.316846592 ! T ! P ! cuft",
["e12U.S.gal"] = "v * 3.785411784 < 1000 ! T ! P ! l",
["e12USgal"] = "v * 3.785411784 < 1000 ! T ! P ! l",
["e15cuft"] = "v * 2.8316846592 < 100 ! e12 ! e15 ! m3",
["e15m3"] = "Pcuft",
["e3bdft"] = "v * 0.23597372167 < 100 ! e3 ! e6 ! m3",
["e3cuft"] = "v * 2.8316846592 < 100 ! ! e3 ! m3",
["e3impgal"] = "v * 4.54609 < 1000 ! k ! M ! l",
["e3m3"] = "v < 28.316846592 ! k ! M ! cuft",
["e3U.S.gal"] = "v * 3.785411784 < 1000 ! k ! M ! l",
["e3USgal"] = "v * 3.785411784 < 1000 ! k ! M ! l",
["e6bdft"] = "v * 0.23597372167 < 100 ! e3 ! e6 ! m3",
["e6cuft"] = "v * 2.8316846592 < 100 ! e3 ! e6 ! m3",
["e6cuyd"] = "v * 7.64554857984 < 10 ! e3 ! e6 ! m3",
["e6impgal"] = "v * 4.54609 < 1000 ! M ! G ! l",
["e6L"] = "USgal",
["e6m3"] = "v < 28.316846592 ! M ! G ! cuft",
["e6U.S.gal"] = "v * 3.785411784 < 1000 ! M ! G ! l",
["e6USgal"] = "v * 3.785411784 < 1000 ! M ! G ! l",
["e9bdft"] = "v * 0.23597372167 < 100 ! e6 ! e9 ! m3",
["e9cuft"] = "v * 2.8316846592 < 100 ! e6 ! e9 ! m3",
["e9impgal"] = "v * 4.54609 < 1000 ! G ! T ! l",
["e9m3"] = "v < 28.316846592 ! G ! T ! cuft",
["e9U.S.gal"] = "v * 3.785411784 < 1000 ! G ! T ! l",
["e9USgal"] = "v * 3.785411784 < 1000 ! G ! T ! l",
["GL"] = "cuft",
["Gl"] = "cuft",
["kL"] = "cuft",
["kl"] = "cuft",
["km<sup>3</sup>"] = "cumi",
["mL"] = "impoz usoz",
["ml"] = "impoz usoz",
["Ml"] = "v < 28.316846592 ! e3 ! e6 ! cuft",
["ML"] = "v < 28.316846592 ! e3 ! e6 ! cuft",
["TL"] = "cumi",
["Tl"] = "cumi",
["μL"] = "cuin",
["μl"] = "cuin",
}
---------------------------------------------------------------------------
-- Do not change the data in this table because it is created by running --
-- a script that reads the wikitext from a wiki page (see note above). --
---------------------------------------------------------------------------
local link_exceptions = {
-- Prefixed units with a linked article different from that of the base unit.
-- Each key item is a prefixed symbol (not unitcode).
["mm<sup>2</sup>"] = "Square millimetre",
["cm<sup>2</sup>"] = "Square centimetre",
["dm<sup>2</sup>"] = "Square decimetre",
["km<sup>2</sup>"] = "Square kilometre",
["kJ"] = "Kilojoule",
["MJ"] = "Megajoule",
["GJ"] = "Gigajoule",
["TJ"] = "Terajoule",
["fm"] = "Femtometre",
["pm"] = "Picometre",
["nm"] = "Nanometre",
["μm"] = "Micrometre",
["mm"] = "Millimetre",
["cm"] = "Centimetre",
["dm"] = "Decimetre",
["dam"] = "Decametre",
["hm"] = "Hectometre",
["km"] = "Kilometre",
["Mm"] = "Megametre",
["Gm"] = "Gigametre",
["Tm"] = "Terametre",
["Pm"] = "Petametre",
["Em"] = "Exametre",
["Zm"] = "Zettametre",
["Ym"] = "Yottametre",
["μg"] = "Microgram",
["mg"] = "Milligram",
["kg"] = "Kilogram",
["Mg"] = "Tonne",
["yW"] = "Yoctowatt",
["zW"] = "Zeptowatt",
["aW"] = "Attowatt",
["fW"] = "Femtowatt",
["pW"] = "Picowatt",
["nW"] = "Nanowatt",
["μW"] = "Microwatt",
["mW"] = "Milliwatt",
["kW"] = "Kilowatt",
["MW"] = "Megawatt",
["GW"] = "Gigawatt",
["TW"] = "Terawatt",
["PW"] = "Petawatt",
["EW"] = "Exawatt",
["ZW"] = "Zettawatt",
["YW"] = "Yottawatt",
["as"] = "Attosecond",
["fs"] = "Femtosecond",
["ps"] = "Picosecond",
["ns"] = "Nanosecond",
["μs"] = "Microsecond",
["ms"] = "Millisecond",
["ks"] = "Kilosecond",
["Ms"] = "Megasecond",
["Gs"] = "Gigasecond",
["Ts"] = "Terasecond",
["Ps"] = "Petasecond",
["Es"] = "Exasecond",
["Zs"] = "Zettasecond",
["Ys"] = "Yottasecond",
["mm<sup>3</sup>"] = "Cubic millimetre",
["cm<sup>3</sup>"] = "Cubic centimetre",
["dm<sup>3</sup>"] = "Cubic decimetre",
["dam<sup>3</sup>"] = "Cubic decametre",
["km<sup>3</sup>"] = "Cubic kilometre",
["μL"] = "Microlitre",
["μl"] = "Microlitre",
["mL"] = "Millilitre",
["ml"] = "Millilitre",
["cL"] = "Centilitre",
["cl"] = "Centilitre",
["dL"] = "Decilitre",
["dl"] = "Decilitre",
["daL"] = "Decalitre",
["dal"] = "Decalitre",
["hL"] = "Hectolitre",
["hl"] = "Hectolitre",
["kL"] = "Kilolitre",
["kl"] = "Kilolitre",
["ML"] = "Megalitre",
["Ml"] = "Megalitre",
["GL"] = "Gigalitre",
["Gl"] = "Gigalitre",
["TL"] = "Teralitre",
["Tl"] = "Teralitre",
["PL"] = "Petalitre",
["Pl"] = "Petalitre",
}
---------------------------------------------------------------------------
-- Do not change the data in this table because it is created by running --
-- a script that reads the wikitext from a wiki page (see note above). --
---------------------------------------------------------------------------
local per_unit_fixups = {
-- Automatically created per units of form "x/y" may have their unit type
-- changed, for example, "length/time" is changed to "speed".
-- Other adjustments can also be specified.
["/area"] = "per unit area",
["/volume"] = "per unit volume",
["area/area"] = "area per unit area",
["energy/length"] = "energy per unit length",
["energy/mass"] = "energy per unit mass",
["energy/time"] = { utype = "power", link = "Power (physics)" },
["energy/volume"] = "energy per unit volume",
["force/area"] = { utype = "pressure", link = "Pressure" },
["length/length"] = { utype = "gradient", link = "Grade (slope)" },
["length/time"] = { utype = "speed", link = "Speed" },
["length/time/time"] = { utype = "acceleration", link = "Acceleration" },
["mass/area"] = { utype = "pressure", multiplier = 9.80665 },
["mass/length"] = "linear density",
["mass/mass"] = "concentration",
["mass/power"] = "mass per unit power",
["mass/time"] = "mass per unit time",
["mass/volume"] = { utype = "density", link = "Density" },
["power/mass"] = "power per unit mass",
["power/volume"] = { link = "Power density" },
["pressure/length"] = "fracture gradient",
["speed/time"] = { utype = "acceleration", link = "Acceleration" },
["volume/area"] = "volume per unit area",
["volume/length"] = "volume per unit length",
["volume/time"] = "flow",
}
return {
all_units = all_units,
default_exceptions = default_exceptions,
link_exceptions = link_exceptions,
per_unit_fixups = per_unit_fixups,
}
8d4f7e3d03f55a7683bae4e0b800b77ac91d44a2
Module:Convert/text
828
90
184
183
2023-10-01T08:32:39Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- Text used by Module:Convert for enwiki.
-- This is a separate module to simplify translation for use on another wiki.
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
-- Some units accept an SI prefix before the unit code, such as "kg" for kilogram.
local SIprefixes = {
-- The prefix field is what the prefix should be, if different from the prefix used.
['Q'] = { exponent = 30, name = 'quetta', },
['R'] = { exponent = 27, name = 'ronna', },
['Y'] = { exponent = 24, name = 'yotta', },
['Z'] = { exponent = 21, name = 'zetta', },
['E'] = { exponent = 18, name = 'exa' , },
['P'] = { exponent = 15, name = 'peta' , },
['T'] = { exponent = 12, name = 'tera' , },
['G'] = { exponent = 9, name = 'giga' , },
['M'] = { exponent = 6, name = 'mega' , },
['k'] = { exponent = 3, name = 'kilo' , },
['h'] = { exponent = 2, name = 'hecto', },
['da']= { exponent = 1, name = 'deca' , name_us = 'deka' },
['d'] = { exponent = -1, name = 'deci' , },
['c'] = { exponent = -2, name = 'centi', },
['m'] = { exponent = -3, name = 'milli', },
['μ'] = { exponent = -6, name = 'micro', }, -- key = 'GREEK SMALL LETTER MU' (U+03BC) utf-8 CE BC
['µ'] = { exponent = -6, name = 'micro', prefix = 'μ' }, -- key = 'MICRO SIGN' (U+00B5) utf-8 C2 B5
['u'] = { exponent = -6, name = 'micro', prefix = 'μ' }, -- not an SI prefix, but allow for people typing this
['n'] = { exponent = -9, name = 'nano' , },
['p'] = { exponent =-12, name = 'pico' , },
['f'] = { exponent =-15, name = 'femto', },
['a'] = { exponent =-18, name = 'atto' , },
['z'] = { exponent =-21, name = 'zepto', },
['y'] = { exponent =-24, name = 'yocto', },
['r'] = { exponent =-27, name = 'ronto', },
['q'] = { exponent =-30, name = 'quecto', },
}
-- Some units can be qualified with one of the following prefixes, when linked.
local customary_units = {
{ "US", link = "United States customary units" },
{ "U.S.", link = "United States customary units" },
{ "imperial", link = "Imperial units" },
{ "imp", link = "Imperial units" },
}
-- Names when using engineering notation (a prefix of "eN" where N is a number; example "e6km").
-- key = { "name", link = "article title", exponent = numeric_key_value }
-- If lk=on and link is defined, the name of the number will appear as a link.
local eng_scales = {
["3"] = { "thousand", exponent = 3 },
["6"] = { "million", exponent = 6 },
["9"] = { "billion", link = "1000000000 (number)", exponent = 9 },
["12"] = { "trillion", link = "1000000000000 (number)", exponent = 12 },
["15"] = { "quadrillion", link = "1000000000000000 (number)", exponent = 15 },
}
local all_categories = {
unit = "[[Category:Convert errors]]",
option = "[[Category:Convert errors]]",
warning = '[[Category:Convert invalid options]]',
tracking = '[[Category:Convert tracking]]',
}
-- For some error messages, the following puts the wanted style around
-- each unit code marked like '...%{ft%}...'.
local unitcode_regex = '%%([{}])'
local unitcode_replace = { ['{'] = '"', ['}'] = '"' } -- no longer need the more elaborate substitute used before 2013-09-28
-- All messages that may be displayed if a problem occurs.
local all_messages = {
-- Message format string: $1=title, $2=text, $3=category, $4=anchor.
-- Each displayed message starts with "Convert:" so can easily locate by searching article.
cvt_format = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[<i>[[Help:Convert messages#$4|<span title="Convert: $1">convert: $2</span>]]</i>]</sup>$3<span class="error"></span>',
cvt_format2 = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[[Help:Convert messages#$4|<span title="Convert: $1">$2</span>]]</sup>$3<span class="error"></span>',
cvt_format_preview = '<strong class="error">Error in convert: $1 [[Help:Convert messages#$4|(help)]]</strong>$3',
-- Each of following messages is a table:
-- { [1] = 'title', -- mouseover title text
-- [2] = 'text', -- link text displayed in article
-- [3] = 'category key', -- key to lookup category in all_categories
-- [4] = 'anchor', -- anchor for link to relevant section on help page
-- regex = gsub_regex,
-- replace = gsub_table,
-- } Mouseover title text Link text CatKey Anchor
cvt_bad_input = { 'input "$1" must be a number and unit' , 'invalid input' , 'option', 'invalid_input' },
cvt_bad_num = { 'Value "$1" must be a number' , 'invalid number' , 'option', 'invalid_number' },
cvt_big_prec = { 'Precision "$1" is too large' , 'precision too large' , 'option', 'precision_too_large' },
cvt_invalid_num = { 'Number has overflowed' , 'number overflow' , 'option', 'number_overflow' },
cvt_no_num = { 'Needs the number to be converted' , 'needs a number' , 'option', 'needs_number' },
cvt_no_num2 = { 'Needs another number for a range' , 'needs another number', 'option', 'needs_another_number' },
cvt_bad_altitude = { '"$1" needs an integer' , 'invalid altitude' , 'option', 'invalid_altitude' },
cvt_bad_frac = { '"$1" needs an integer above 1' , 'invalid fraction' , 'option', 'invalid_fraction' },
cvt_bad_prec = { 'Precision "$1" must be an integer' , 'invalid precision' , 'option', 'invalid_precision' },
cvt_bad_sigfig = { '"$1" needs a positive integer' , 'invalid sigfig' , 'option', 'invalid_sigfig' },
cvt_empty_option = { 'Ignored empty option "$1"' , 'empty option' , 'option', 'empty_option' },
cvt_deprecated = { 'Option "$1" is deprecated' , '*' , 'option', 'deprecated_option', format = 'cvt_format2', nowarn = true },
cvt_no_spell = { 'Spelling is not available' , 'bug, ask for help' , 'option', 'ask_for_help' },
cvt_unknown_option = { 'Ignored invalid option "$1"' , 'invalid option' , 'option', 'invalid_option' },
cvt_wd_fail = { 'Unable to access Wikidata' , 'wikidata problem' , 'option', 'wikidata_problem' },
cvt_bad_default = { 'Unit "$1" has an invalid default' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_bad_unit = { 'Unit "$1" is invalid here' , 'unit invalid here' , 'unit' , 'unit_invalid_here' },
cvt_no_default = { 'Unit "$1" has no default output unit' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_no_unit = { 'Needs name of unit' , 'needs unit name' , 'unit' , 'needs_unit_name' },
cvt_unknown = { 'Unit name "$1" is not known' , 'unknown unit' , 'unit' , 'unknown_unit' },
cvt_should_be = { '$1' , 'ambiguous unit' , 'unit' , 'ambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_mismatch = { 'Cannot convert "$1" to "$2"' , 'unit mismatch' , 'unit' , 'unit_mismatch' },
cvt_bug_convert = { 'Bug: Cannot convert between specified units', 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_lookup = { 'Unit "$1" is incorrectly defined' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
}
-- Text to join input value/unit with output value/unit.
local disp_joins = {
-- [1]=before output, [2]=after output, [3]=between outputs in a combination; default "; "
-- [wantname] gives default abbr=off
["or"] = { " or " , "" , " or ", wantname = true },
["sqbr-sp"] = { " [" , "]" },
["sqbr-nbsp"] = { " [" , "]" },
["comma"] = { ", " , "" , ", " },
["semicolon"] = { "; " , "" },
["slash-sp"] = { " / " , "" , wantname = true },
["slash-nbsp"] = { " / ", "" , wantname = true },
["slash-nosp"] = { "/" , "" , wantname = true },
["b"] = { " (" , ")" },
["(or)"] = { " (" , ")", " or " },
["br"] = { "<br />" , "" , wantname = true },
["br()"] = { "<br />(" , ")", wantname = true },
}
-- Text to separate values in a range.
local range_types = {
-- Specifying a table requires either:
-- * "off" and "on" values (for "abbr=off" and "abbr=on"), or
-- * "input" and "output" values (for LHS and RHS);
-- other fields are optional.
-- When "adj=on|abbr=off" applies, spaces in range text are replaced with hyphens.
-- With "exception = true", that also occurs with "adj=on|abbr=on".
-- If "adj" is defined here, that text (unchanged) is used with "adj=on".
["+"] = " + ",
[","] = ", ",
[", and"] = ", and ",
[", or"] = ", or ",
["by"] = " by ",
["-"] = "–",
["to about"] = " to about ",
["and"] = { off = " and ", on = " and ", exception = true },
["and(-)"] = { input = " and ", output = "–" },
["or"] = { off = " or " , on = " or " , exception = true },
["to"] = { off = " to " , on = " to " , exception = true },
["to(-)"] = { input = " to ", output = "–" },
["+/-"] = { off = " ± ", on = " ± ", adj = " ± ", is_range_change = true },
["by(x)"] = { input = " by ", output = " × ", out_range_x = true },
["x"] = { off = " by ", on = " × ", abbr_range_x = true },
["xx"] = " × ",
["*"] = "×",
["/"] = " / ", -- for a table of high/low temperatures with {{convert|83|/|63|F|disp=br()|abbr=values}}
}
local range_aliases = {
-- ["alternative name for a range"] = "standard range name"
["–"] = "-",
["–"] = "-",
["×"] = "x",
["×"] = "x",
["±"] = "+/-",
["±"] = "+/-",
}
-- Convert accepts range text delimited with whitespace, for example, {{convert|1 to 2|ft}}.
-- In addition, the following "words" are accepted without spaces, for example, {{convert|1-2|ft}}.
-- Words must be in correct order for searching, for example, 'x' after 'xx'.
local range_words = { '-', '–', 'xx', 'x', '*' }
local ranges = {
types = range_types,
aliases = range_aliases,
words = range_words,
}
-- Valid option names.
local en_option_name = {
-- ["local text for option name"] = "en name used in this module"
["$"] = "$",
["abbr"] = "abbr",
["adj"] = "adj",
["altitude_ft"] = "altitude_ft",
["altitude_m"] = "altitude_m",
["comma"] = "comma",
["debug"] = "debug",
["disp"] = "disp",
["frac"] = "frac",
["input"] = "input",
["lang"] = "lang",
["lk"] = "lk",
["order"] = "order",
["qid"] = "qid",
["qual"] = "qual",
["qualifier"] = "qual",
["round"] = "round",
["sigfig"] = "sigfig",
["sing"] = "adj", -- "sing" is an old alias for "adj"
["sortable"] = "sortable",
["sp"] = "sp",
["spell"] = "spell",
["stylein"] = "stylein",
["styleout"] = "styleout",
["tracking"] = "tracking",
}
-- Valid option values.
-- Convention: parms.opt_xxx refers to an option that is set here
-- (not intended to be set by the template which invokes this module).
-- Example: At enwiki, "abbr" includes:
-- ["values"] = "opt_values"
-- As a result, if the template uses abbr=values, Module:Convert sets:
-- parms["opt_values"] = true
-- parms["abbr"] = nil
-- Therefore parms.abbr will be nil, or will have one of the listed values
-- that do not start with "opt_".
-- An option value of form "xxx?" is the same as "xxx" but shows the input as deprecated.
local en_option_value = {
["$"] = 'TEXT', -- TEXT should be a currency symbol that will be used instead of "$"
["abbr"] = {
-- ["local text for option value"] = "en value used in this module"
["def"] = "", -- ignored (some wrapper templates call convert with "abbr=def" to mean "default abbreviation")
["h"] = "on", -- abbr=on + use "h" for hand unit (default)
["hh"] = "opt_hand_hh", -- abbr=on + use "hh" for hand unit
["in"] = "in", -- use symbol for LHS unit
["none"] = "off", -- old name for "off"
["off"] = "off", -- use name for all units
["on"] = "on", -- use symbol for all units
["out"] = "out", -- use symbol for RHS unit (default)
["unit"] = "unit", -- abbr=on but abbreviate units only: e6km → million km (not ×10⁶ km)
["values"] = "opt_values", -- show only input and output numbers, not units
["~"] = "opt_also_symbol", -- show input unit symbol as well as name
},
["adj"] = {
["mid"] = "opt_adjectival, opt_adj_mid", -- adj=on with user-specified text after input unit (between input and output)
["off"] = "", -- ignored (off is the default)
["on"] = "opt_adjectival", -- unit name is singular and hyphenated
["pre"] = "opt_one_preunit", -- user-specified text before input unit
["ri0"] = "opt_ri=0", -- round input with precision = 0
["ri1"] = "opt_ri=1", -- round input with precision = 1
["ri2"] = "opt_ri=2", -- round input with precision = 2
["ri3"] = "opt_ri=3", -- round input with precision = 3
},
["altitude_ft"] = 'INTEGER',
["altitude_m"] = 'INTEGER',
["comma"] = {
["5"] = "opt_comma5", -- only use numsep grouping if 5 or more digits
["gaps"] = "opt_gaps", -- use gaps, not numsep, to separate groups of digits
["gaps3"] = "opt_gaps, opt_gaps3", -- group only in threes rather than default of no gap before a single digit after decimal mark
["off"] = "opt_nocomma", -- no numsep in input or output numbers
},
["debug"] = {
["yes"] = "opt_sortable_debug", -- make the normally hidden sort key visible
},
["disp"] = {
["5"] = "opt_round=5?", -- round output value to nearest 5
["b"] = "b", -- join: '(...)'
["(or)"] = "(or)", -- join: '(...)' with 'or' between outputs in a combination
["br"] = "br", -- join: '<br />'
["br()"] = "br()", -- join: '<br />(...)'
["comma"] = "comma", -- join: ','
["flip"] = "opt_flip", -- reverse order of input/output
["number"] = "opt_output_number_only", -- display output value (not input, and not output symbol/name)
["or"] = "or", -- join: 'or'
["out"] = "opt_output_only",
["output number only"] = "opt_output_number_only",
["output only"] = "opt_output_only",
["preunit"] = "opt_two_preunits", -- user-specified text before input and output units
["semicolon"] = "semicolon", -- join: ';'
["sqbr"] = "sqbr", -- join: '[...]'
["table"] = "opt_table", -- output is suitable for a table cell with align="right"
["tablecen"] = "opt_tablecen", -- output is suitable for a table cell with align="center"
["unit"] = "opt_input_unit_only", -- display input symbol/name (not output, and not input value)
["unit or text"] = "opt_input_unit_only, opt_ignore_error", -- display input symbol/name, or given unit code if not known
["unit2"] = "opt_output_unit_only",
["x"] = "x", -- join: <first>...<second> (user-specified text)
},
["frac"] = 'INTEGER',
["input"] = 'TEXT', -- TEXT should be value><space><unitcode> or <wikidata-property-id>
["lang"] = { -- language for output digits (both en and local digits are always accepted for input)
["en"] = "opt_lang_en", -- use en digits for numbers, regardless of local language
["local"] = "opt_lang_local", -- use local digits for numbers (default, although config can change default to en)
},
["lk"] = {
["in"] = "in", -- link LHS unit name or symbol
["off"] = "off", -- do not link: same as default except for hand unit
["on"] = "on", -- link all unit names or symbols (but not twice for the same unit)
["out"] = "out", -- link RHS unit name or symbol
},
["order"] = {
["flip"] = "opt_flip", -- reverse order of input/output
["out"] = "opt_order_out", -- do not show input; instead, use order in output combination, with the first output shown as the input
},
["qid"] = 'TEXT', -- TEXT should be a Wikidata Q item identifier
["qual"] = 'TEXT', -- TEXT should be a Wikidata Q item identifier
["round"] = {
["0.5"] = "opt_round=0.5", -- round output value to nearest 0.5
["5"] = "opt_round=5", -- round output value to nearest 5
["10"] = "opt_round=10", -- round output value to nearest 10 (same as but clearer than "|-1")
["25"] = "opt_round=25", -- round output value to nearest 25
["50"] = "opt_round=50", -- round output value to nearest 50
["each"] = "opt_round_each", -- using default precision in a range, round each output separately (default uses highest precision of each item in range)
},
["sigfig"] = 'INTEGER',
["sortable"] = {
["off"] = "", -- ignored (off is the default)
["on"] = "opt_sortable_on", -- output sort key for use in a sortable table, based on value from converting to a standard base unit
["debug"] = "opt_sortable_on, opt_sortable_debug", -- |sortable=debug is the same as |sortable=on|debug=yes
},
["sp"] = {
["us"] = "opt_sp_us", -- use U.S. spelling (like "meter" instead of default "metre")
},
["spell"] = { -- only English spelling is supported; not scientific notation; only some fractions
["in"] = "opt_spell_in", -- spell input value in words
["In"] = "opt_spell_in, opt_spell_upper", -- spell input value in words with first letter uppercase
["on"] = "opt_spell_in, opt_spell_out", -- spell input and output values in words
["On"] = "opt_spell_in, opt_spell_out, opt_spell_upper", -- same, with first letter of first word in result uppercase
["us"] = "opt_sp_us", -- use U.S. spelling; same as sp=us so spell=us also works
},
["stylein"] = 'TEXT',
["styleout"] = 'TEXT',
["tracking"] = 'TEXT',
}
local titles = {
["frac"] = "Fraction/styles.css",
["sfrac"] = "Sfrac/styles.css",
}
return {
SIprefixes = SIprefixes,
all_categories = all_categories,
all_messages = all_messages,
currency = { ['$'] = true, ['£'] = true, ['€'] = true, ['₱'] = true, ['₽'] = true, ['¥'] = true },
customary_units = customary_units,
disp_joins = disp_joins,
en_option_name = en_option_name,
en_option_value = en_option_value,
eng_scales = eng_scales,
ranges = ranges,
titles = titles,
}
ff98cf24da87736f3469f82401084ca608335d55
Module:InfoboxImage
828
91
186
185
2023-10-01T08:32:42Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- Inputs:
-- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link
-- page - page to display for multipage images (DjVu)
-- size - size to display the image
-- maxsize - maximum size for image
-- sizedefault - default size to display the image if size param is blank
-- alt - alt text for image
-- title - title text for image
-- border - set to yes if border
-- center - set to yes, if the image has to be centered
-- upright - upright image param
-- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it
-- link - page to visit when clicking on image
-- class - HTML classes to add to the image
-- Outputs:
-- Formatted image.
-- More details available at the "Module:InfoboxImage/doc" page
local i = {};
local placeholder_image = {
"Blue - Replace this image female.svg",
"Blue - Replace this image male.svg",
"Female no free image yet.png",
"Flag of None (square).svg",
"Flag of None.svg",
"Flag of.svg",
"Green - Replace this image female.svg",
"Green - Replace this image male.svg",
"Image is needed female.svg",
"Image is needed male.svg",
"Location map of None.svg",
"Male no free image yet.png",
"Missing flag.png",
"No flag.svg",
"No free portrait.svg",
"No portrait (female).svg",
"No portrait (male).svg",
"Red - Replace this image female.svg",
"Red - Replace this image male.svg",
"Replace this image female (blue).svg",
"Replace this image female.svg",
"Replace this image male (blue).svg",
"Replace this image male.svg",
"Silver - Replace this image female.svg",
"Silver - Replace this image male.svg",
"Replace this image.svg",
"Cricket no pic.png",
"CarersLogo.gif",
"Diagram Needed.svg",
"Example.jpg",
"Image placeholder.png",
"No male portrait.svg",
"Nocover-upload.png",
"NoDVDcover copy.png",
"Noribbon.svg",
"No portrait-BFD-test.svg",
"Placeholder barnstar ribbon.png",
"Project Trains no image.png",
"Image-request.png",
"Sin bandera.svg",
"Sin escudo.svg",
"Replace this image - temple.png",
"Replace this image butterfly.png",
"Replace this image.svg",
"Replace this image1.svg",
"Resolution angle.png",
"Image-No portrait-text-BFD-test.svg",
"Insert image here.svg",
"No image available.png",
"NO IMAGE YET square.png",
"NO IMAGE YET.png",
"No Photo Available.svg",
"No Screenshot.svg",
"No-image-available.jpg",
"Null.png",
"PictureNeeded.gif",
"Place holder.jpg",
"Unbenannt.JPG",
"UploadACopyrightFreeImage.svg",
"UploadAnImage.gif",
"UploadAnImage.svg",
"UploadAnImageShort.svg",
"CarersLogo.gif",
"Diagram Needed.svg",
"No male portrait.svg",
"NoDVDcover copy.png",
"Placeholder barnstar ribbon.png",
"Project Trains no image.png",
"Image-request.png",
"Noimage.gif",
}
function i.IsPlaceholder(image)
-- change underscores to spaces
image = mw.ustring.gsub(image, "_", " ");
assert(image ~= nil, 'mw.ustring.gsub(image, "_", " ") must not return nil')
-- if image starts with [[ then remove that and anything after |
if mw.ustring.sub(image,1,2) == "[[" then
image = mw.ustring.sub(image,3);
image = mw.ustring.gsub(image, "([^|]*)|.*", "%1");
assert(image ~= nil, 'mw.ustring.gsub(image, "([^|]*)|.*", "%1") must not return nil')
end
-- Trim spaces
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
assert(image ~= nil, "mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1') must not return nil")
-- remove prefix if exists
local allNames = mw.site.namespaces[6].aliases
allNames[#allNames + 1] = mw.site.namespaces[6].name
allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName
for i, name in ipairs(allNames) do
if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then
image = mw.ustring.sub(image, mw.ustring.len(name) + 2);
break
end
end
-- Trim spaces
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
-- capitalise first letter
image = mw.ustring.upper(mw.ustring.sub(image,1,1)) .. mw.ustring.sub(image,2);
for i,j in pairs(placeholder_image) do
if image == j then
return true
end
end
return false
end
function i.InfoboxImage(frame)
local image = frame.args["image"];
if image == "" or image == nil then
return "";
end
if image == " " then
return image;
end
if frame.args["suppressplaceholder"] ~= "no" then
if i.IsPlaceholder(image) == true then
return "";
end
end
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "http:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "[http:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[[http:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "https:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[https:" then
return "";
end
if mw.ustring.lower(mw.ustring.sub(image,1,8)) == "[[https:" then
return "";
end
if mw.ustring.sub(image,1,2) == "[[" then
-- search for thumbnail images and add to tracking cat if found
local cat = "";
if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then
cat = "[[Category:Pages using infoboxes with thumbnail images]]";
end
return image .. cat;
elseif mw.ustring.sub(image,1,2) == "{{" and mw.ustring.sub(image,1,3) ~= "{{{" then
return image;
elseif mw.ustring.sub(image,1,1) == "<" then
return image;
elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then
-- Found strip marker at begining, so pass don't process at all
return image;
elseif mw.ustring.sub(image,4,9) == "`UNIQ-" then
-- Found strip marker at begining, so pass don't process at all
return image;
else
local result = "";
local page = frame.args["page"];
local size = frame.args["size"];
local maxsize = frame.args["maxsize"];
local sizedefault = frame.args["sizedefault"];
local alt = frame.args["alt"];
local link = frame.args["link"];
local title = frame.args["title"];
local border = frame.args["border"];
local upright = frame.args["upright"] or "";
local thumbtime = frame.args["thumbtime"] or "";
local center = frame.args["center"];
local class = frame.args["class"];
-- remove prefix if exists
local allNames = mw.site.namespaces[6].aliases
allNames[#allNames + 1] = mw.site.namespaces[6].name
allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName
for i, name in ipairs(allNames) do
if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then
image = mw.ustring.sub(image, mw.ustring.len(name) + 2);
break
end
end
if maxsize ~= "" and maxsize ~= nil then
-- if no sizedefault then set to maxsize
if sizedefault == "" or sizedefault == nil then
sizedefault = maxsize
end
-- check to see if size bigger than maxsize
if size ~= "" and size ~= nil then
local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0;
local maxsizenumber = tonumber(mw.ustring.match(maxsize,"%d*")) or 0;
if sizenumber>maxsizenumber and maxsizenumber>0 then
size = maxsize;
end
end
end
-- add px to size if just a number
if (tonumber(size) or 0) > 0 then
size = size .. "px";
end
-- add px to sizedefault if just a number
if (tonumber(sizedefault) or 0) > 0 then
sizedefault = sizedefault .. "px";
end
result = "[[File:" .. image;
if page ~= "" and page ~= nil then
result = result .. "|page=" .. page;
end
if size ~= "" and size ~= nil then
result = result .. "|" .. size;
elseif sizedefault ~= "" and sizedefault ~= nil then
result = result .. "|" .. sizedefault;
else
result = result .. "|frameless";
end
if center == "yes" then
result = result .. "|center"
end
if alt ~= "" and alt ~= nil then
result = result .. "|alt=" .. alt;
end
if link ~= "" and link ~= nil then
result = result .. "|link=" .. link;
end
if border == "yes" then
result = result .. "|border";
end
if upright == "yes" then
result = result .. "|upright";
elseif upright ~= "" then
result = result .. "|upright=" .. upright;
end
if thumbtime ~= "" then
result = result .. "|thumbtime=" .. thumbtime;
end
if class ~= nil and class ~= "" then
result = result .. "|class=" .. class;
end
-- if alt value is a keyword then do not use as a description
if alt == "thumbnail" or alt == "thumb" or alt == "frameless" or alt == "left" or alt == "center" or alt == "right" or alt == "upright" or alt == "border" or mw.ustring.match(alt or "", '^[0-9]*px$', 1) ~= nil then
alt = nil;
end
if title ~= "" and title ~= nil then
-- does title param contain any templatestyles? If yes then set to blank.
if mw.ustring.match(frame:preprocess(title), 'UNIQ%-%-templatestyles', 1) ~= nil then
title = nil;
end
end
if title ~= "" and title ~= nil then
result = result .. "|" .. title;
end
result = result .. "]]";
return result;
end
end
return i;
0ee5fe75ba239fc5c9cedc81ca11bdc0be068542
Template:-
10
92
188
187
2023-10-01T08:32:44Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Clear]]
{{Redirect category shell|
{{R from modification}}
{{R from template shortcut}}
}}
3fb0b377ebee11659e4a3ba0034f60898dbc473f
Template:Convert
10
93
190
189
2023-10-01T08:32:45Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{{{{♥|safesubst:}}}#invoke:convert|convert}}</includeonly><noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage, interwikis to Wikidata, not here -->
</noinclude>
952ac4080dc4a427c4a65db9951c8a4f4c91c626
Template:Small
10
94
192
191
2023-10-01T08:32:45Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<span style="font-size:85%;">{{{1}}}</span><includeonly>{{SAFESUBST:#if:{{{1|}}}||[[Category:Pages using small with an empty input parameter]]}}</includeonly><noinclude>
{{Documentation}}<!--Categories and interwikis go in the /doc sub-page.-->
</noinclude>
76d3535c2917cc3bfb1b032506073faa15e1a480
Module:Labelled list hatnote
828
95
194
193
2023-10-01T08:32:47Z
Reverie
2
1 revision imported
Scribunto
text/plain
--------------------------------------------------------------------------------
-- Labelled list --
-- --
-- This module does the core work of creating a hatnote composed of a list --
-- prefixed by a colon-terminated label, i.e. "LABEL: [andList of pages]", --
-- for {{see also}} and similar templates. --
--------------------------------------------------------------------------------
local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local yesno --initialize lazily
local p = {}
-- Defaults global to this module
local defaults = {
label = 'See also', --Final fallback for label argument
labelForm = '%s: %s',
prefixes = {'label', 'label ', 'l'},
template = 'Module:Labelled list hatnote'
}
-- Localizable message strings
local msg = {
errorSuffix = '#Errors',
noInputWarning = 'no page names specified',
noOutputWarning =
"'''[[%s]] — no output: none of the target pages exist.'''"
}
-- Helper function that pre-combines display parameters into page arguments.
-- Also compresses sparse arrays, as a desirable side-effect.
function p.preprocessDisplays (args, prefixes)
-- Prefixes specify which parameters, in order, to check for display options
-- They each have numbers auto-appended, e.g. 'label1', 'label 1', & 'l1'
prefixes = prefixes or defaults.prefixes
local indices = {}
local sparsePages = {}
for k, v in pairs(args) do
if type(k) == 'number' then
indices[#indices + 1] = k
local display
for i = 1, #prefixes do
display = args[prefixes[i] .. k]
if display then break end
end
sparsePages[k] = display and
string.format('%s|%s', string.gsub(v, '|.*$', ''), display) or v
end
end
table.sort(indices)
local pages = {}
for k, v in ipairs(indices) do pages[#pages + 1] = sparsePages[v] end
return pages
end
--Helper function to get a page target from a processed page string
--e.g. "Page|Label" → "Page" or "Target" → "Target"
local function getTarget(pagename)
local pipe = string.find(pagename, '|')
return string.sub(pagename, 0, pipe and pipe - 1 or nil)
end
-- Produces a labelled pages-list hatnote.
-- The main frame (template definition) takes 1 or 2 arguments, for a singular
-- and (optionally) plural label respectively:
-- * {{#invoke:Labelled list hatnote|labelledList|Singular label|Plural label}}
-- The resulting template takes pagename & label parameters normally.
function p.labelledList (frame)
mArguments = require('Module:Arguments')
yesno = require('Module:Yesno')
local labels = {frame.args[1] or defaults.label}
labels[2] = frame.args[2] or labels[1]
labels[3] = frame.args[3] --no defaulting
labels[4] = frame.args[4] --no defaulting
local template = frame:getParent():getTitle()
local args = mArguments.getArgs(frame, {parentOnly = true})
local pages = p.preprocessDisplays(args)
local options = {
category = yesno(args.category),
extraclasses = frame.args.extraclasses,
ifexists = yesno(frame.args.ifexists),
namespace = frame.args.namespace or args.namespace,
selfref = yesno(frame.args.selfref or args.selfref),
template = template
}
return p._labelledList(pages, labels, options)
end
function p._labelledList (pages, labels, options)
if options.ifexists then
for k = #pages, 1, -1 do --iterate backwards to allow smooth removals
local v = pages[k]
local title = mw.title.new(getTarget(v), namespace)
if (v == '') or title == nil or not title.exists then
table.remove(pages, k)
end
end
end
labels = labels or {}
label = (#pages == 1 and labels[1] or labels[2]) or defaults.label
for k, v in pairs(pages) do
if mHatnote.findNamespaceId(v) ~= 0 then
label =
(
#pages == 1 and
(labels[3] or labels[1] or defaults.label) or
(labels[4] or labels[2] or defaults.label)
) or defaults.label
end
end
if #pages == 0 then
if options.ifexists then
mw.addWarning(
string.format(
msg.noOutputWarning, options.template or defaults.template
)
)
return ''
else
return mHatnote.makeWikitextError(
msg.noInputWarning,
(options.template or defaults.template) .. msg.errorSuffix,
options.category
)
end
end
local text = string.format(
options.labelForm or defaults.labelForm,
label,
mHatlist.andList(pages, true)
)
local hnOptions = {
extraclasses = options.extraclasses,
selfref = options.selfref
}
return mHatnote._hatnote(text, hnOptions)
end
return p
b7a8ba27cf6195e6427701b94e8d2acad3c40a21
Template:Further
10
96
196
195
2023-10-01T08:32:48Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#invoke:labelled list hatnote|labelledList|Further information{{#if:{{{topic|}}}| on {{{topic|}}}}}}}</includeonly><noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->
</noinclude>
dd29c6dfb3894a2dc3f20144a654b7012c9a9214
Template:WPMILHIST Infobox style
10
97
198
197
2023-10-01T08:32:49Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#switch:{{{1|}}}
|main_box=class="{{#if:{{{2|}}}|infobox {{{2}}}|infobox}}" style="{{#invoke:Data|Module:WPMILHIST Infobox style|main_box_raw}}"
|{{#invoke:Data|Module:WPMILHIST Infobox style|{{{1|}}}}}
}}</includeonly><noinclude>
{{documentation}}
</noinclude>
b117547056afc703e2f1371497b0a53fa5a22751
Module:Data
828
98
200
199
2023-10-01T08:32:49Z
Reverie
2
1 revision imported
Scribunto
text/plain
local mt = {}
function mt.__index(t, k)
return function(frame)
local data = mw.loadData(k)
local i = 1
for _,v in ipairs(frame.args) do
local ty = type(data)
if ty ~= 'table' then
local args = {}
for j = 1, i - 1 do
args[j] = frame.args[j]
end
if frame.args.softfail then
return '<span class="error">[[Category:Pages with failed Module:Data lookups]]Error: Tried to read index "' .. mw.text.nowiki(v) .. '" of mw.loadData("' .. mw.text.nowiki(k) .. '").' .. mw.text.nowiki(table.concat(args, '.')) .. ', which is a ' .. ty .. '</span>'
else
error('Tried to read index "' .. v .. '" of mw.loadData("' .. k .. '").' .. table.concat(args, '.') .. ', which is a ' .. ty)
end
end
data = data[v]
i = i + 1
end
return data
end
end
return setmetatable({}, mt)
654c5ba2e0c73e7415457ca7a67fe0dfacfdba3b
Module:WPMILHIST Infobox style
828
99
202
201
2023-10-01T08:32:49Z
Reverie
2
1 revision imported
Scribunto
text/plain
local retval = {
main_box_raw_auto_width = 'border-spacing:2px;',
header_raw = 'background-color:#C3D6EF;text-align:center;vertical-align:middle;font-size:110%;',
sub_header_raw = 'background-color:#DCDCDC;text-align:center;vertical-align:middle;',
header_color = 'background-color:#C3D6EF;',
nav_box = 'margin:0;float:right;clear:right;width:25.5em;margin-bottom:0.5em;margin-left:1em;',
nav_box_child = 'margin:0;float:right;clear:right;width:25em;margin-bottom:0.5em;',
nav_box_wide = '',
nav_box_header = 'background-color:#C3D6EF;',
nav_box_wide_header = 'background-color:#C3D6EF;',
nav_box_label = 'background-color:#DCDCDC;',
image_box_raw = 'text-align:center;border-bottom:1px solid #aaa;line-height:1.5em;',
image_box_plain_raw = 'text-align:center;line-height:1.5em;',
internal_border = '1px dotted #aaa;',
section_border = '1px solid #aaa;'
}
retval.main_box_raw = 'width:25.5em;' .. retval.main_box_raw_auto_width
retval.header_bar = 'style="' .. retval.header_raw .. '"'
retval.sub_header_bar = 'style="' .. retval.sub_header_raw .. '"'
retval.image_box = 'style="' .. retval.image_box_raw .. '"'
retval.image_box_plain = 'style="' .. retval.image_box_plain_raw .. '"'
return retval
0f9ea47bc17e40cdabbae6de54f63e40ae502f8e
Template:Date
10
100
204
203
2023-10-01T08:32:50Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{safesubst:<noinclude/>#switch:none
|{{safesubst:<noinclude/>#iferror: {{safesubst:<noinclude/>#time:Y_M_d|{{{1|}}} }} | none }} <noinclude><!-- #time: can't handle --></noinclude>
|{{safesubst:<noinclude/>#iferror: {{safesubst:<noinclude/>#expr: {{{1|}}}+0 }}
|<noinclude><!--not a pure number--></noinclude>
|{{safesubst:<noinclude/>#ifexpr: {{{1|}}}+0 > 10000000000000
|<noinclude><!-- a yyyymmddhhmmss timestamp --></noinclude>
|{{safesubst:<noinclude/>#ifeq: {{safesubst:<noinclude/>#expr:{{{1|}}}+0}} | {{{1|}}}
| none <noinclude><!-- pure number eg 123.456 --></noinclude>
| <noinclude><!-- assume yy-mm-dd --></noinclude>
}}
}}
}}
|{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc:{{{2|}}}}} | none | asis | link | lnone =none }}
|{{safesubst:<noinclude/>#ifexpr: {{safesubst:<noinclude/>#time:Y|{{{1|}}} }} < 1000 | none }}
|{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>#time:Ynj|{{{1|}}} }}|100031|110031|130031|140031|150031=none}}
|= {{safesubst:<noinclude/>#if:{{{1|}}}
|{{safesubst:<noinclude/>#switch:{{{2}}}
|link|lnone|l=[[{{{1}}}]]
|{{{1}}}
}}
}}<noinclude><!-- error or "none", so no formatting --></noinclude>
|<noinclude><!-- continue with formatting --></noinclude>
{{safesubst:<noinclude/>#ifeq:<noinclude><!--
--></noinclude>{{safesubst:<noinclude/>#time:Y|{{{1}}} 2008}}<noinclude><!--
--></noinclude>{{safesubst:<noinclude/>#iferror: {{safesubst:<noinclude/>#ifexpr: {{{1}}}>10000000000000 | no }} | }}<noinclude><!--
--></noinclude>{{safesubst:<noinclude/>#time:Y|{{{1}}} 2004}}
|20082004
|<noinclude><!-- no year --></noinclude>
{{safesubst:<noinclude/>#ifeq:{{safesubst:<noinclude/>#time:d|{{{1}}} 2036}}|{{safesubst:<noinclude/>#time:d|{{{1}}} }}
|<noinclude><!-- month+day --></noinclude>{{safesubst:<noinclude/>#time:
{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc: {{safesubst:<noinclude/>#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
| lmdy | liso | lymd = [[:F j]]
| mdy | iso | ymd = F j
| ldmy | l = [[:j F]]
| #default = j F
}}|{{{1}}} 2000 }}<noinclude><!-- default='dmy' or null or "" or unsupported option --></noinclude>
|<noinclude><!-- month only --></noinclude>{{safesubst:<noinclude/>#time:
{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc: {{safesubst:<noinclude/>#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
| lmdy | liso | lymd
| ldmy | l = [[F]]
| #default = F
}}|{{{1}}} 2000 }}<noinclude><!-- default='dmy'/'mdy'/'ymd'/'iso'/null/""/unsupported opt --></noinclude>
}}
|<noinclude><!-- with year--></noinclude>
{{safesubst:<noinclude/>#if: {{safesubst:<noinclude/>#iferror:{{safesubst:<noinclude/>#time:j|2 {{{1|}}}}}|*D*|{{safesubst:<noinclude/>#iferror:{{safesubst:<noinclude/>#time:j|2000 {{{1|}}}}}|*D*| }}}}
|<noinclude><!-- day+month+year --></noinclude>{{safesubst:<noinclude/>#time:
{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc: {{safesubst:<noinclude/>#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
| lmdy = [[:F j]], [[Y]]
| mdy = F j, Y
| liso = [[Y|Y-]][[F j|m-d]]<noinclude><!-- i.e. [[Y-m-d]] --></noinclude>
| iso = Y-m-d
| lymd = [[Y]] [[:F j]]
| ymd = Y F j
| ldmy | l = [[:j F]] [[Y]]
| #default = j F Y
}}|{{{1|}}} }}<noinclude><!-- #default='dmy' or null or "" or unsupported option --></noinclude>
|<noinclude><!-- month+year --></noinclude>{{safesubst:<noinclude/>#time:
{{safesubst:<noinclude/>#switch: {{safesubst:<noinclude/>lc: {{safesubst:<noinclude/>#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
| lmdy | liso | lymd | ldmy | l = [[:F Y]]
| #default = F Y
}}|{{{1|}}} }}<noinclude><!-- default='dmy'/'iso'/'mdy'/null/""/unsupported option --></noinclude>
}}
}}
}}<noinclude>
{{documentation}}
</noinclude>
931e7e4d742cf61660be218f2d435de20a5bcc00
Template:Country data Spain
10
101
206
205
2023-10-01T08:32:50Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{ {{{1<noinclude>|country showdata</noinclude>}}}
| alias = Spain
| flag alias = Flag of Spain.svg
| flag alias-1506 = Flag of Cross of Burgundy.svg
| flag alias-1701 = Bandera de España 1701-1748.svg
| flag alias-1748 = Bandera de España 1748-1785.svg
| flag alias-1760 = Bandera de España 1760-1785.svg
| flag alias-1785 = Flag of Spain (1785–1873, 1875–1931).svg
| flag alias-1873 = Flag of the First Spanish Republic.svg
| flag alias-1874 = Flag of Spain (1785–1873, 1875–1931).svg
| flag alias-1931 = Flag of Spain (1931–1939).svg
| flag alias-civil-1931 = Flag of the Second Spanish Republic (plain).svg
| flag alias-1936 = Bandera del bando nacional 1936-1938.svg
| flag alias-1938 = Flag of Spain (1938–1945).svg
| flag alias-1945 = Flag of Spain (1945–1977).svg
| flag alias-1977 = Flag of Spain (1977–1981).svg
| flag alias-civil = Flag of Spain (Civil).svg
| flag alias-civil-1785 = BandMercante1785.svg
| flag alias-navy = Flag of Spain.svg
| link alias-navy = Spanish Navy
| flag alias-marines = Flag of Spain.svg
| link alias-marines = Spanish Marine Infantry
| flag alias-army = Flag of Spain.svg
| link alias-army = Spanish Army
| flag alias-naval = Naval Jack of Spain.svg
| link alias-naval = Spanish Navy
| flag alias-air force = Flag of Spain.svg
| link alias-air force = Spanish Air and Space Force
| size = {{{size|}}}
| name = {{{name|}}}
| altlink = {{{altlink|}}}
| variant = {{{variant|}}}
<noinclude>
| var1 = 1506
| var2 = 1701
| var3 = 1748
| var4 = 1760
| var5 = 1785
| var6 = 1873
| var7 = 1874
| var8 = 1931
| var9 = civil-1931
| var10 = 1936
| var11 = 1938
| var12 = 1945
| var13 = 1977
| var14 = civil
| var15 = civil-1785
| redir1 = ESP
| redir2 = SPA
| related1 = Spanish Empire
| related2 = Kingdom of Spain
| related3 = Spanish Republic
| related4 = Spanish State
| related5 = Francoist Spain
</noinclude>
}}
a27e5d2bc6539467e8a94c500b05f5caf7b87dff
Template:Collapse top
10
102
208
207
2023-10-01T08:32:51Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<div style="margin-left:{{{indent|0}}}"><!-- NOTE: width renders incorrectly if added to main STYLE section -->
{| <!-- Template:Collapse top --> class="mw-collapsible mw-archivedtalk {{<includeonly>safesubst:</includeonly>#if:{{{expand|{{{collapse|}}}}}}||mw-collapsed}} {{{class|}}}" style="background: {{{bg1|transparent}}}; text-align: left; border: {{{border|1px}}} solid {{{b-color|Silver}}}; margin: 0.2em auto auto; width:{{<includeonly>safesubst:</includeonly>#if:{{{width|}}}|{{{width}}}|100%}}; clear: {{{clear|both}}}; padding: 1px;"
|-
! style="background: {{{bg|#{{main other|F0F2F5|CCFFCC}}}}}; font-size:87%; padding:0.2em 0.3em; text-align:{{<includeonly>safesubst:</includeonly>#if:{{{left|}}}|left|{{<includeonly>safesubst:</includeonly>#if:{{{align|}}}|left|center}}}}; {{<includeonly>safesubst:</includeonly>#if:{{{fc|}}}|color: {{{fc}}};|}}" | <div style="font-size:115%;{{<includeonly>safesubst:</includeonly>#if:{{{left|}}}||margin:0 4em}}">{{{1|{{{title|{{{reason|{{{header|{{{heading|{{{result|Extended content}}}}}}}}}}}}}}}}}}</div>
{{<includeonly>safesubst:</includeonly>#if:{{{warning|{{{2|}}}}}}
|{{<includeonly>safesubst:</includeonly>!}}-
{{<includeonly>safesubst:</includeonly>!}} style="text-align:center; font-style:italic;" {{<includeonly>safesubst:</includeonly>!}} {{{2|The following is a closed discussion. {{strongbad|Please do not modify it.}} }}} }}
|-
| style="border: solid {{{border2|1px Silver}}}; padding: {{{padding|0.6em}}}; background: {{{bg2|White}}};" {{<includeonly>safesubst:</includeonly>!}}<noinclude>
{{lorem ipsum|3}}
{{Collapse bottom}}
{{Documentation}}
</noinclude>
247cc43d5198baf8804d0926529cbbdd7be91113
Template:Collapse bottom
10
103
210
209
2023-10-01T08:32:51Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>|}</div></includeonly><noinclude>
{{Documentation|Template:Collapse top/doc}}
<!-- PLEASE ADD THIS TEMPLATE'S CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS -->
</noinclude>
64b210e8ab0882b262da50e9fbccf2132bc34fab
Template:Further information
10
104
212
211
2023-10-01T08:32:52Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Further]]
{{R from move}}
42879303989bb2724f884c7b099077b50c789c48
Template:Infobox ship begin
10
105
214
213
2023-10-01T08:32:54Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<noinclude>{{Being deleted|2022 April 30|Template:Infobox ship begin|merge= Template:Infobox ship}}</noinclude><includeonly>{{WPMILHIST Infobox style|main_box}}
{{#if:{{{infobox caption|}}}|{{!}}+{{#switch:{{{infobox caption}}}
|yes={{#invoke:WPSHIPS_utilities|ship_name_format|name={{PAGENAME}} |adj=off |showerrs={{{showerrs|}}} |sclass={{{sclass|}}}}}<!-- set to 2 for non-italicized class name -->
|nodab={{#invoke:WPSHIPS_utilities|ship_name_format|name={{PAGENAME}}|dab=none |showerrs={{{showerrs|}}} }}
|#default={{{infobox caption}}}}}<!-- end switch -->}}{{#if:{{{display title|}}}|{{#switch:{{{display title}}}|
|none=<!-- do nothing -->
|ital={{italic title}}
|#default={{DISPLAYTITLE:{{{display title}}}}}}}|{{DISPLAYTITLE:{{#invoke:WPSHIPS_utilities|ship_name_format|sclass={{{sclass|}}}|name={{FULLPAGENAME}}}}}}}}</includeonly><noinclude>{{documentation}}</noinclude>
53cce220e7675139aa6cba793b8faec6e8829fe0
Template:Infobox ship characteristics
10
106
216
215
2023-10-01T08:32:55Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<noinclude>{{Being deleted|2022 April 30|Template:Infobox ship begin|merge= Template:Infobox ship}}</noinclude><includeonly>{{#invoke:WPSHIPS utilities|infobox_ship_characteristics}}</includeonly><noinclude>{{Documentation}}</noinclude>
0eb21c64bbfb588d69c0f1c898c9b67540c0b0ac
Template:Infobox ship image
10
107
218
217
2023-10-01T08:32:55Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<noinclude>{{Being deleted|2022 April 30|Template:Infobox ship begin|merge= Template:Infobox ship}}</noinclude><includeonly>| colspan="2" {{WPMILHIST Infobox style|image_box_plain}} | {{#if:{{{image|{{{Ship image|}}}}}}|{{#invoke:InfoboxImage|InfoboxImage|image={{{image|{{{Ship image|}}}}}}|size={{{Ship image size|{{{image size|}}}}}}|sizedefault=300px|upright=1|alt={{{image alt|}}}}}{{#if:{{{caption|{{{Ship caption|}}}}}}|<div>{{{caption|{{{Ship caption|}}}}}}</div>}}|{{#switch:{{NAMESPACENUMBER}}|0|118=[[Category:Ship infoboxes without an image]]}}}}</includeonly>{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using infobox ship image with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Infobox ship image]] with unknown parameter "_VALUE_"|ignoreblank=y| caption | image | image alt | image size | Ship caption | Ship image | Ship image size }}<noinclude>{{Documentation}}</noinclude>
8e5f680a92029e6e100520769241b6951a052cd4
Module:WPSHIPS utilities
828
108
220
219
2023-10-01T08:32:56Z
Reverie
2
1 revision imported
Scribunto
text/plain
require('strict')
local get_args = require ('Module:Arguments').getArgs;
local styles = require ('Module:WPMILHIST Infobox style'); -- infobox css
local data = mw.loadData ('Module:WPSHIPS utilities/data');
local namespace = mw.title.getCurrentTitle().namespace; -- used for categorization
--[[--------------------------< E R R O R _ M A P _ T >--------------------------------------------------------
]]
local error_map_t = { -- [1] is error message; [2] is error category
synonymous = {'has synonymous parameter', 'Category:Pages using infobox ship with synonymous parameters'};
missing = {'missing required parameter: %s', 'Category:WPSHIPS: sclass and sclass2 errors'},
format = {'invalid format code: %s. Should be 0–5, or blank', 'Category:WPSHIPS: sclass and sclass2 errors'},
}
--[[--------------------------< E R R O R _ M S G _ M A K E >--------------------------------------------------
assembles an error message from message text and category in <error_map_t>. creates a help link to the category
page; categorizes only main and template namespaces.
<no_cat> disables categorization for those templates that support it; to disable categorization set <no_cat> true
]]
local function error_msg_make (msg_idx, template, detail, no_cat)
local out = {};
local category;
table.insert (out, '<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">Error: '); --TODO: simplify?
if template then
table.insert (out, table.concat ({'{{', template, '}} '})); -- TODO: get template names for synonymous parameter errors
end
table.insert (out, string.format (error_map_t[msg_idx][1], detail)); -- build error message from base + <detail>
table.insert (out, table.concat ({' ([[:', error_map_t[msg_idx][2], '|help]])'})); -- help text on category pages; TODO: help text on template pages also?
table.insert (out, '</span>');
if (0 == namespace or 10 == namespace) and not no_cat then -- categorize in article space (and template space to take care of broken usages)
table.insert (out, table.concat ({'[[', error_map_t[msg_idx][2], ']]'}));
end
return table.concat (out); -- make a big string and done
end
--[[--------------------------< I S _ S E T >------------------------------------------------------------------
Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
]]
local function is_set( var )
return not (var == nil or var == '');
end
--[[--------------------------< S I Z E O F _ S H I P _ T Y P E >----------------------------------------------
Returns the size in words of ship type. Inputs are the fragment table, the number of elements in the fragment table,
and the number of words that make up nationality.
The number of fragments (words) in a ship name dictate the possible sizes of ship type. If nationality takes one fragment,
and ship type takes four fragments, then the minimum number of fragments in a composite ship name is:
5 = 1 (nationality) + 3 (ship type) + 1 (ship name) (same as 4 fragments (words) after nationality)
This function starts at the longest possible series of fragments that might be ship type. This order is important becuase
some ship types might begin with similar fragments: 'ship' and 'ship of the line'. Starting with the least possible
series of fragments (1) would find 'ship' and make 'of the line' part of the italicized name.
Returns 0 if there is no recognizable ship type.
]]
local function sizeof_ship_type (frag, frag_len, nat_len)
local ship_type;
if 5 <= (frag_len - nat_len) then -- must have at least five fragments after nationality for four-word ship type
ship_type = table.concat (frag, ' ', nat_len+1, nat_len+4); -- four-word ship type
if data.ship_type_t[ship_type] then
return 4;
end
end
if 4 <= (frag_len - nat_len) then -- must have at least four fragments after nationality for three-word ship type
ship_type = table.concat (frag, ' ', nat_len+1, nat_len+3); -- three-word ship type
if data.ship_type_t[ship_type] then
return 3;
end
end
if 3 <= (frag_len - nat_len) then -- must have at least three fragments after nationality for two-word ship type
ship_type = table.concat (frag, ' ', nat_len+1, nat_len+2); -- two-word ship type
if data.ship_type_t[ship_type] then
return 2;
end
end
if 2 <= (frag_len - nat_len) then -- must have at least two fragments after nationality for one-word ship type
if data.ship_type_t[frag[nat_len+1]] then -- one-word ship type
return 1;
end
end
return 0; -- no recognizable ship type
end
--[[--------------------------< S I Z E O F _ N A T I O N A L I T Y >------------------------------------------
This function the size (in words) of the nationality from the fragments table. Nationality may be one or two
words that occupy the first one or two positions in the table.
Returns the number of words that identify the nationality:
1 for French or German, etc.
2 for United States;
0 when table doesn't have a recognizable nationality
]]
local function sizeof_nationality (frag, frag_len)
local nat = '';
if not data.nationality_t [frag[1]] then -- if not a one-word nationality
if 2 <= frag_len - 2 then -- must have at least two fragments after nationality for minimal ship type and name
nat = table.concat (frag, ' ', 1, 2);
if data.nationality_t [nat] then -- is it a two-word nationality?
return 2; -- yes
else
return 0; -- no
end
end
return 0; -- not one-word and not enough fragments for two-word
end
return 1; -- one-word nationality
end
--[[-------------------------< D O _ S H I P _ N A M E _ F O R M A T >-----------------------------------------
This function applies correct styling to ship and ship-class names. These names are, for example, ship-article titles
used by templates {{navsource}}, {{Infobox ship begin}}, where the article title is to be rendered with proper
styling.
This function requires one argument:
|name= (required): a name is required; if missing or empty, this function returns an error message (may or may not be visible depending on where it is used)
used in {{infobox ship begin}} to provide a value for {{DISPLAYTITLE:}} and to provide a value for |infobox caption=
{{#invoke:WPSHIPS_utilities|ship_name_format|name={{PAGENAME}}}}
Optional arguments to support {{infobox ship begin}}:
|dab=none – displays ship name without parenthetical disambiguator; use when |infobox caption=nodab
|sclass=2 – for ship classes only; displays class name without italics (parameter name is loosely similar to {{slcass2}} which does the same thing); use when |infobox caption=class
|adj=off – for ship classes only; displays class name as a noun (no hyphen, no ship type); use when |infobox caption=class
Arguments are passed in a table.
to call this function locally:
do_ship_name_format ({['name=name'], ['dab']=dab, ['sclass']=sclass, ['adj']=adj, ['showerrs']=showerrs}) or
args = {['name=name'], ['dab']=dab, ['sclass']=sclass, ['adj']=adj, ['showerrs']=showerrs};
do_ship_name_format (args)
The function returns the formatted name or, if unable to format the name, the original name and an unformatted error message.
]]
local function do_ship_name_format (args)
local name_sans_dab; -- the ship or class name without a trailing parenthetical dab
local dab; -- the dab stripped from the name
local fragments = {}; -- a table of words that make up name_sans_dab
local ship_type; -- a word or phrase that describes a ship
local type_len; -- the number of words that describe a ship
local nat_len; -- the number of words used to specify a ship's nationality
local name = ''; -- the reassembles and formatted ship name
local error_msg = ''; -- a repository for error messages if any
-- args.name = mw.text.decode (args.name); -- replace html entities in title with their characters; doesn't work for & and & in prefix
args.name = args.name:gsub ("'", "\'"); -- replace html appostrophe with the character
-- args.name = args.name:gsub ("&", "&");
-- args.name = args.name:gsub ("&", "&");
-- args.name = args.name:gsub ("&", "&");
if args.name:match ('.+%-class%s+%a+') then -- if a ship-class
fragments = mw.text.split (args.name, '-class' ); -- split at -class
if '2' == args.sclass then -- for DISPLAYTITLE and infobox caption when class not named for a member of the class
if 'off' == args.adj then
return fragments[1] .. ' class'; -- for infobox caption do noun form <name> class (no hyphen, no ship type)
end
return args.name; -- nothing to do so return original unformatted name
end
if 'off' == args.adj then
return "''" .. fragments[1] .. "'' class"; -- for infobox caption do noun form <name> class (no hyphen, no ship type)
end
return "''" .. fragments[1] .. "''-class" .. fragments[2]; -- and return formatted adjectival name
end
-- not a ship class so try to format a ship name
name_sans_dab, dab = args.name:match('^(.+)%s+(%b())%s*$'); -- split name into name_sans_dab and dab
if is_set (dab) then
dab = ' ' .. dab; -- insert a space for later reassembly
else
name_sans_dab = args.name; -- because without a dab, the string.match returns nil
dab = ''; -- empty string for concatenation
end
fragments = mw.text.split (name_sans_dab, '%s' ); -- split into a table of separate words
nat_len = sizeof_nationality (fragments, #fragments); -- get the number of words in the ship's nationality
if 0 < nat_len then -- if not zero we have a valid nationality
type_len = sizeof_ship_type (fragments, #fragments, nat_len); -- get the number of words in the ship type
if 0 < type_len then -- if not zero, ship type is valid; nationality and type not italics, the rest is name
name = "''" .. table.concat (fragments, ' ', nat_len + type_len + 1) .. "''"; -- format name
if 'none' == args.dab then -- for |infobox caption=nodab
return name; -- return the formatted name without the nationality or ship type or dab
end
name = table.concat (fragments, ' ', 1, nat_len + type_len) .. " " .. name; -- assemble everything but dab
else
error_msg = ' unrecognized ship type;'; -- valid nationality, invalid ship type
end
elseif data.ship_prefix_t[fragments[1]] then -- if the first fragment is a ship prefix
name = table.remove (fragments, 1); -- fetch it from the table
name = name .. " ''" .. table.concat (fragments, ' ') .. "''"; -- assemble formatted name
else
error_msg = ' no nationality or prefix;'; -- invalid nationality and first word in ship name not a valid prefix
end
if is_set (name) then -- name will be set if we were able to format it
if 'none' == args.dab then -- for |infobox caption=nodab
return name; -- return the formatted name without the dab
end
return name .. dab; -- return the formatted name with the dab
end
if is_set (dab) then
if dab:match ('%(%u+[%- ]?%d+%)') or -- one or more uppercase letters, optional space or hyphen, one or more digits
dab:match ('%(%d+[%- ]?%u+%)') or -- one or more digits, optional space or hyphen, one or more uppercase letters
dab:match ('%(%u[%u%-]*%-%d+%)') or -- one or more uppercase letters with hyphens, a hyphen, one or more digits (e.g., T-AO-157)
dab:match ('%([12]%d%d%d%)') then -- four digits representing year in the range 1000–2999
name = "''" .. table.concat (fragments, ' ') .. "''"; -- format the name
if 'none' == args.dab then -- for |infobox caption=nodab
return name; -- return the formatted name without the dab
end
return name .. dab; -- return the formatted name with the dab
end
-- last chance, is there a ship type in the dab?
for key, _ in pairs (data.ship_type_t) do -- spin through the ship type list and see if there is a ship type (key) in the dab
if dab:find ('%f[%a]' .. key .. '%f[^%a]') then -- avoid matches that are not whole word
name = "''" .. table.concat (fragments, ' ') .. "''"; -- format the name
if 'none' == args.dab then -- for |infobox caption=nodab
return name; -- return the formatted name without the dab
end
return name .. dab; -- return the formatted name with the dab
end
end
error_msg = error_msg .. ' no ship type in dab;';
if 'none' == args.dab then -- for |infobox caption=nodab
return table.concat (fragments, ' '), error_msg; -- return the unformatted name without the dab, and an error message
end
end
return args.name, error_msg; -- return original un-formatted name with unformatted error message if any
end
--[[-------------------------< S H I P _ N A M E _ F O R M A T >-----------------------------------------------
This function is the external interface to do_ship_name_format().
The function requires one parameter:
|name= (required): a name is required; if missing or empty, this function returns an error message (may or may not be visible depending on where it is used)
used in {{infobox ship begin}} to provide a value for {{DISPLAYTITLE:}} and to provide a value for |infobox caption=
{{#invoke:WPSHIPS_utilities|ship_name_format|name={{PAGENAME}}}}
Optional parameters to support {{infobox ship begin}}:
|dab=none – displays ship name without parenthetical disambiguator; use when |infobox caption=nodab
|sclass=2 – for ship classes only; displays class name without italics (parameter name is loosely similar to {{slcass2}} which does the same thing); use when |infobox caption=class
|adj=off – for ship classes only; displays class name as a noun (no hyphen, no ship type); use when |infobox caption=class
Other optional parameters:
|showerrs=yes – marginally useful; can display error messages if the module invocation is not buried in a template
Values from the above parameters are placed in a table and that table passed as an argument in the call to do_ship_name_format().
do_ship_name_format() returns two strings: a name and an error message. If do_ship_name_format() could format the name, it returns the formatted name and
an empty string for the error message. If it could not format the name, do_ship_name_format() returns the original name and an error message.
Formatting of the error message, in response to |showerrs=yes is the responsibility of the calling function.
]]
local function ship_name_format(frame)
local name = ''; -- destination of the formatted ship name
local error_msg = ''; -- destination of any error message
if not is_set (frame.args.name) then -- if a ship name not provided
if 'yes' == frame.args.showerrs then -- and we're supposed to show errors
error_msg = '<span style="font-size:100%; font-weight:normal" class="error">Empty name</span>'; -- return an empty string error message if there is no name
end
else
name, error_msg = do_ship_name_format (frame.args); -- get formatted name and error message
if is_set (error_msg) and 'yes' == frame.args.showerrs then -- if appropriate, show error message
error_msg = '<span style="font-size:100%; font-weight:normal" class="error">' .. error_msg .. '</span>';
else
error_msg = ''; -- for concatenation
end
end
return name .. error_msg; -- return name and error message
end
--[[--------------------------< H N S A >----------------------------------------------------------------------
Similar to {{navsource}}, this code supports {{hnsa}} by attempting to construct a link to a ship article at the
the Historic Nava Ships Association website.
The template has the form:
{{hnsa|<page>|<name>}}
where:
<page> is the name of the page at http://hnsa.org/hnsa-ships/<page>
<name> (optional) is the name of the ship; if left blank, the template uses the current page title; if a ship name, it is formatted
from which this code produces:
[http://hnsa.org/hnsa-ships/<page> <name>] at Historic Naval Ships Association
]]
local function hnsa (frame)
local pframe = frame:getParent() -- get arguments from calling template frame
local ship_name = '';
local error_msg = '';
local article_title = mw.title.getCurrentTitle().text; -- fetch the article title
if not is_set (pframe.args[1]) then
return '<span style="font-size:100%; font-weight:normal" class="error">missing hsna page</span>';
end
local fmt_params = {['name']='', ['showerrs']=nil};
if is_set (pframe.args.showerrs) then -- if showerrs set in template, override showerrs in #invoke:
fmt_params.showerrs = pframe.args.showerrs; -- template value
else
fmt_params.showerrs = frame.args.showerrs; -- invoke value
end
if is_set (pframe.args[2]) then
fmt_params.name = pframe.args[2];
else
fmt_params.name = article_title; -- use article title
end
ship_name, error_msg = do_ship_name_format (fmt_params);
if is_set (error_msg) and is_set (pframe.args[2]) then -- if unable to format the name
local escaped_name = pframe.args[2]:gsub("([%(%)%.%-])", "%%%1"); -- escape some of the Lua magic characters
if pframe.args[2] == article_title or -- is name same as article title?
nil ~= article_title:find ('%f[%a]' .. escaped_name .. '%f[%s]') or -- is name a word or words substring of article title?
nil ~= article_title:find ('%f[%a]' .. escaped_name .. '$') then -- is name a word or words substring that ends article title?
ship_name = "''" .. pframe.args[2] .. "''"; -- non-standard 'name'; perhaps just the name without prefix and dab;
error_msg = ''; -- unset because we think we have a name
end
end
if is_set (error_msg) and 'yes' == fmt_params.showerrs then
error_msg = '<span style="font-size:100%; font-weight:normal" class="error">' .. error_msg .. '</span>';
else
error_msg = ''; -- unset so it doesn't diplay
end
local output = {
'[http://www.hnsa.org/hnsa-ships/',
pframe.args[1],
'/ ',
ship_name,
'] at Historic Naval Ships Association',
error_msg,
}
return table.concat (output);
end
--[[--------------------------< N A V S O U R C E >------------------------------------------------------------
This version of the template {{navsource}} was added as a test vehicle for do_ship_name_format().
]]
local function navsource (frame)
local pframe = frame:getParent() -- get arguments from calling template frame
local ship_name = '';
local error_msg = '';
local article_title = mw.title.getCurrentTitle().text; -- fetch the article title
if not is_set (pframe.args[1]) then
return '<span style="font-size:100%; font-weight:normal" class="error">missing navsource URLcode</span>';
end
local fmt_params = {['name']='', ['showerrs']=nil};
if is_set (pframe.args.showerrs) then -- if showerrs set in template, override showerrs in #invoke:
fmt_params.showerrs = pframe.args.showerrs; -- template value
else
fmt_params.showerrs = frame.args.showerrs; -- invoke value
end
if is_set (pframe.args[2]) then
fmt_params.name = pframe.args[2];
else
fmt_params.name = article_title; -- use article title
end
ship_name, error_msg = do_ship_name_format (fmt_params);
if is_set (error_msg) and is_set (pframe.args[2]) then -- if unable to format the name
local escaped_name = pframe.args[2]:gsub("([%(%)%.%-])", "%%%1"); -- escape some of the Lua magic characters
if pframe.args[2] == article_title or -- is name same as article title?
nil ~= article_title:find ('%f[%a]' .. escaped_name .. '%f[%s]') or -- is name a word or words substring of article title?
nil ~= article_title:find ('%f[%a]' .. escaped_name .. '$') then -- is name a word or words substring that ends article title?
ship_name = "''" .. pframe.args[2] .. "''"; -- non-standard 'name'; perhaps just the name without prefix and dab;
error_msg = ''; -- unset because we think we have a name
end
end
if is_set (error_msg) and 'yes' == fmt_params.showerrs then
error_msg = '<span style="font-size:100%; font-weight:normal" class="error">' .. error_msg .. '</span>';
else
error_msg = ''; -- unset so it doesn't diplay
end
local output = {
'[http://www.navsource.org/archives/',
pframe.args[1],
'.htm Photo gallery] of ',
ship_name,
' at NavSource Naval History',
error_msg,
}
return table.concat (output);
end
--[[--------------------------< _ S H I P >--------------------------------------------------------------------
This is a possible replacement for the template {{ship}}. It has better error detection and handling.
]]
local function _ship (prefix, name, dab, control, unlinked_prefix, unlinked_whole)
local error_msg = '';
local category = '';
if not is_set (control) then
control = ''; -- if not provided, ensure that control is empty string for comparisons
elseif control:find ('%-') then -- shortcut for |link=no when using a format control parameter ...|SSBN-659|-6}} same as ...|SSBN-659|6|link=no}}
unlinked_whole = true; -- set the unlinked flag
control = control:match ('%d'); -- strip out the hyphen
end
-- dispose of error conditions straight away
if not is_set (name) then -- this is the only required parameter
error_msg = ' missing name';
elseif not is_set (dab) and ('1' == control or '3' == control or '5' == control) then -- dab required when control value set to expect it
error_msg = ' missing disambiguator';
elseif not is_set (prefix) and ('5' == control or '6' == control) then -- prefix required when control value set to expect it
error_msg = ' missing prefix';
elseif '4' == control then -- displaying only the prefix
error_msg = 'invalid control parameter: ' .. control;
elseif is_set (control) then
if ('number' ~= type (tonumber (control))) or (1 > tonumber (control) or 6 < tonumber (control)) then -- control must be a number between 1 through 6
error_msg = 'invalid control parameter: ' .. control;
end
elseif not is_set (prefix) and unlinked_prefix then -- prefix required when |up=yes
error_msg = ' missing prefix';
end
if is_set (error_msg) then
if 0 == mw.title.getCurrentTitle().namespace then -- only categorize pages in article space
category = '[[Category:WPSHIPS: template ship parameter errors]]';
end
return '<span style="font-size:100%" class="error">' .. error_msg .. '</span>' .. category; -- return an error message; don't bother with making a link
end
local link_name;
local link = '[[';
if is_set (prefix) then
link = link .. prefix .. ' ' .. name; -- begin assembling the article name portion of the wikilink
else
link = link .. name;
end
if is_set (dab) then
link = link .. ' (' .. dab .. ')'; -- wrap dab in parentheses
end
name = "''" .. name .. "''"; -- name is always italicized so do it now
if '1' == control then
link_name = dab; -- special case when displaying only the dab, don't wrap in parentheses
end
if is_set (dab) then -- for all other cases that display dab
if '5' == control then
dab = " \'\'" .. dab .. "\'\'"; -- for prefix with dab display HMS A1. italicize the dab
else
dab = ' (' .. dab .. ')'; -- except for dab-only, all others display with parentheses
end
end
if not is_set (control) then -- when control not set: prefix, name, and dab
if unlinked_prefix then -- 'unlinked prefix'?
link = prefix .. ' ' .. link; -- yes, modify link so that prefix is not linked in final render
link_name = name .. dab;
elseif is_set (prefix) then
link_name = prefix .. ' ' .. name .. dab;
else
link_name = name .. dab;
end
else -- when control is not 1 or none
if '2' == control then -- name only
link_name = name;
elseif '3' == control then -- name and dab
link_name = name .. dab;
elseif '5' == control then -- prefix and dab
if unlinked_prefix then -- 'unlinked prefix'?
link = prefix .. ' ' .. link; -- yes, modify link so that prefix is not linked in final render
link_name = dab;
else
link_name = prefix .. dab;
end
elseif '6' == control then -- prefix and name
if unlinked_prefix then -- 'unlinked prefix'?
link = prefix .. ' ' .. link; -- yes, modify link so that prefix is not linked in final render
link_name = name;
else
link_name = prefix .. ' ' .. name;
end
end
end
if unlinked_whole then
return link_name;
else
return link .. '|' .. link_name .. ']]';
end
end
--[[--------------------------< S H I P >----------------------------------------------------------------------
This is a possible replacement for the template {{ship}}. It has better error detection and handling.
This function is the externally accessible entry point for template {{ship}}, {{HMS}}, {{USS}}, etc
{{#invoke:WPSHIPS_utilities/sandbox|ship|{{{1|}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}|link={{{link|}}}|up={{{up|}}}}}
]]
local function ship (frame) -- this version not supported from the template yet
local prefix = mw.text.trim (frame.args[1] or ''); -- fetch positional parameters into named variables for readability
local name = mw.text.trim (frame.args[2] or ''); -- stripped of leading and trailing whitespace
local dab = mw.text.trim (frame.args[3] or ''); -- and and set to empty string (is that needed?)
local control = frame.args[4];
local unlinked_prefix = 'yes' == frame.args.up;
local unlinked_whole = 'no' == frame.args.link;
return _ship (prefix, name, dab, control, unlinked_prefix, unlinked_whole);
end
--[[--------------------------< L I S T _ E R R O R >----------------------------------------------------------
Assembles an error message, the original parameter value and, if appropriate a category. The error message precedes
the existing value of the parameter. If the first non-whitespace character in the parameter is a '*', set prefix to
a '*' and sep to '\n'. For line-break lists, set prefix to empty string and sep to '<br />'.
Category is appended to the end of the returned value only for pages in article space.
Inputs:
prefix – a string of characters that precede the error message span; typically '' and '*'
message – the error message to be displayed; goes inside the span
sep – a string of characters that separates the span from the parameter value; typically '\n' and '<br />'
param_val – the unmodified parameter value
showerrs – a boolean, true to display the error message text
]]
local function list_error (prefix, message, sep, param_val, showerrs)
local err_msg = '%s<span style="font-size:100%%" class="error">list error: %s ([[:Category:WPSHIPS:Infobox list errors|help]])</span>%s%s%s';
local category = '';
if 0 == mw.title.getCurrentTitle().namespace then -- only categorize pages in article space
category = '[[Category:WPSHIPS:Infobox list errors]]';
end
if true == showerrs then
return string.format (err_msg, prefix, message, sep, param_val, category); -- put it all together
else
return param_val .. category;
end
end
--[[--------------------------< U N B U L L E T E D _ L I S T >------------------------------------------------
Mediawiki:Common.css imposes limitations on plain, unbulleted lists. The template {{plainlist}} does not render this correctly:
{{plainlist|
*Item 1
*Item 2
**Item 2a
***Item 2a1
**Item 2b
*Item 3}}
The above renders without proper indents for items marked ** and ***.
If the list is not wrapped in {{plainlist}} then the above list is rendered with bullets which is contrary to the Infobox ship usage guide.
This code translates a bulleted list into an html unordered list:
<ul style="list-style:none; margin:0;">
<li>Name 1</li>
<li>Name 2</li>
<ul style="list-style:none">
<li>Subname 2a</li>
<ul style="list-style:none">
<li>Subname 2a1</li>
</ul>
<li>Subname 2b</li>
</ul>
<li>Name 3</li>
</ul>
There are rules:
1. The parameter value must begin with a splat but may have leading and trailing whitespace.
2. Each list item after the first must begin on a new line just as is required by normal bulleted lists.
3. When adding a sublevel, the number of splats may increase by one and never more. This is illegal:
*item
***item
When any of these rules are violated, unbulleted_list() returns the original text and adds the article
to Category:WPSHIPS:Infobox list errors. Error messaging in this function is somewhat sketchy so they are
disabled. After initial adoption, better error messaging could/should be implemented.
This function receives the content of one parameter:
{{#invoke:WPSHIPS utilities|unbulleted_list|{{{param|}}}}}
]]
local function _unbulleted_list (param)
local showerrs = true; -- set to false to hide error messages
local List_item_otag = '<li style="padding-left: .4em; text-indent: -.4em;">'; -- hanging indent markup; everything moves right with padding-left; first line moved left by neg indent
if nil == param:match ('^%s*%*') then -- parameter value must begin with a splat (ignoring leading white space)
if param:match ('<[%s/]*[Bb][Rr][%s/]*>') then -- if the parameter value has a list using variants of <br /> tag
return list_error ('', '<br /> list', '<br />', param, showerrs); -- return an error message with maintenance category
elseif param:match ('<div style="clear:') then
return list_error ('', '{{clear}} list', '<br />', param, showerrs); -- return an error message with maintenance category
elseif param:match ('.+\n%*') then -- if the parameter value has text followed by an unordered list
return list_error ('', 'mixed text and list', '<br />', param, showerrs); -- return an error message with maintenance category
end
return param; -- return the parameter as is
end
local item_table = mw.text.split (mw.text.trim (param), '\n'); -- trim white space from end then make a table of bulleted items by splitting on newlines
if 1 == #item_table then -- if only one bulleted item, no need for a list
return (item_table[1]:gsub ('^%*%s*', '')); -- trim off the splat and any following white space and done
end
if item_table[1]:match ('^%*%*+') then -- if first list item uses more than one splat, that's an error
return list_error ('*', 'too many * at start of list', '\n', param, showerrs); -- return an error message with maintenance category
end
local html_table = {}; -- table to hold the html output
local level = 1; -- used to indicate when a new <ul> is required
local splats = 0; -- number of splats that start each item in the list
local item = ''; -- the item text
table.insert (html_table, '<ul style="list-style:none; margin:0;">') -- this for first <ul> tag; sets no bullets and no indent
for _,v in ipairs (item_table) do
splats, item = v:match ('(%*+)%s*(.*)'); -- split the item into splats and item text
if nil == splats then -- nil if there is an extra line between items
return list_error ('*', 'list item missing markup', '\n', param, showerrs); -- return an error message with maintenance category
elseif '' == item then
return list_error ('*', 'empty list item', '\n', param, showerrs); -- return an error message with maintenance category
elseif item:match ('^[;:]') then -- if the list item is mixed unordered list / description list markup (*:)
return list_error ('*', 'mixed list type', '\n', param, showerrs); -- return an error message with maintenance category
end
splats = splats:len(); -- change string of splats into a number indicating how many splats there are
if splats == level then -- if at the same level as previous item
table.insert (html_table, List_item_otag .. item .. '</li>');
elseif splats == level + 1 then -- number of splats can only increase by one
level = splats; -- record the new level
table.insert (html_table, '<ul style="list-style: none">'); -- add a new sublist
table.insert (html_table, List_item_otag .. item .. '</li>'); -- and the item
elseif splats < level then -- from three splats to one splat for example
while splats < level do
table.insert (html_table, '</ul>'); -- close each sub <ul> until level and splats match
level = level - 1;
end
table.insert (html_table, List_item_otag .. item .. '</li>'); -- add the item
else -- jumping more than one level up – one splat to three splats for example – is an error
return list_error ('*', 'too many asterisks', '\n', param, showerrs); -- return an error message with maintenance category
end
end
while 0 < level do
table.insert (html_table, '</ul>'); -- close each <ul> until level counted down to zero
level = level - 1;
end
return table.concat (html_table, '\n'); -- return the list as a string
end
--[[--------------------------< U N B U L L E T E D _ L I S T >------------------------------------------------
external entry point
]]
local function unbulleted_list (frame)
return _unbulleted_list (frame.args[1])
end
--[=[-------------------------< _I N F O B O X _ S H I P _ F L A G >--------------------------------------------
Output of {{shipboxflag|USA}}:
[[File:Flag of the United States.svg|100x35px|alt=|link=]]
Image syntax:
[[File:Name|Type|Border|Location|Alignment|Size|link=Link|alt=Alt|Caption]]
This function standardizes the size of flag images in the infobox ship career header by simply overwriting the Size
parameter value in the Image wikilink with |100x28px. This size leave a 1px gap between the top and bottom of the flag image and
the header edge. A similar left-side gap of 2px is supplied by {{infobox ship career}}.
]=]
local function _infobox_ship_flag (image)
if image:match ('|[%s%dx]+px%s*') then -- is there a size positional parameter?
image = image:gsub('|[%s%dx]+px%s*', '%|100x28px'); -- overwrite it with |100x28px
else
return '<span style="font-size:100%" class="error">malformed flag image</span>'
end
return image; -- return the modified image
end
--[=[-------------------------< I N F O B O X _ S H I P _ F L A G >--------------------------------------------
external entry point
]=]
local function infobox_ship_flag (frame)
if not is_set (frame.args[1]) then -- if |Ship flag= not set
return ''; -- return empty string
end
return _infobox_ship_flag (frame.args[1]); -- return the modified image
end
--[=[-------------------------< C I T E _ D A N F S _ T I T L E >----------------------------------------------
This function attempts to render a DANFS article title in more or less proper (per Wikipedia) format for the
template {{cite danfs}}. DANFS titles typically take one of four forms:
<ship name> <disambiguator> <hull number>
<ship name> <hull number>
<ship name> <disambiguator>
<ship name>
Here, we extract the various parts, italicize the ship name and reassemble for use by the cite danfs |title= parameter.
To call this function:
|title={{#invoke:WPSHIPS utilities|cite_danfs_title|{{{title}}}}}
]=]
local function cite_danfs_title (frame)
local name;
local disambiguator;
local hullnum;
if not is_set (frame.args[1]) then -- if |title= not set
return ''; -- return empty string
end
name, disambiguator, hullnum = frame.args[1]:match ('(.-)( [XVI]+)( %([^%)]+%))$');
if not (name and disambiguator and hullnum) then
disambiguator = ''; -- empty string for concatenation
name, hullnum = frame.args[1]:match ('(.-)( %([^%)]+%))$');
if not (name and hullnum) then
hullnum = ''; -- empty string for concatenation
name, disambiguator = frame.args[1]:match ('(.-)( [XVI]+)$');
if not (name and disambiguator) then
disambiguator = '';
name = frame.args[1]; -- just a name or something we don't recognize
end
end
end
return table.concat ({"''", name, "''", disambiguator, hullnum}); -- reassemble and done
end
--[[--------------------------< S Y N O N Y M _ C H E C K >----------------------------------------------------
support function for infoboxen functions
there are a handful of infoboxen parameters that are synonymous pairs. This function is called to see if both
of the parameters in a synonymous pair have been assigned a value. When both have assigned values, each gets an
error message appended to it. Most of the synonymous pairs are UK Emglish v US English so the variable names
<args_t> table of template parameters and values
<uk_param> UK English parameter name
<us_param> US English parameter name
<error_flag> boolean that this function sets true when both of a pair are set; controls addition of maint category
]]
local function synonym_check (args_t, uk_param, us_param, error_flag)
if args_t[uk_param] and args_t[us_param] then
args_t[uk_param] = args_t[uk_param] .. error_msg_make ('synonymous'); -- both are set so append error message with category
args_t[us_param] = args_t[us_param] .. error_msg_make ('synonymous', nil, nil, true); -- but append error message without category
return true; -- inform the calling function that it needs to emit maint category
end
return error_flag; -- no match so return unmodified <error_flag>
end
--[[--------------------------< L I N E _ I T E M S >----------------------------------------------------------
support function for infoboxen functions
This function handles all infobox ship parameters that are 'line items' (label followed by value) because all
of these sorts of parameters are rendered with exacty the same formatting.
params_t{} is a table of tables where the params_t{} keys are the template's parameter names. The params_t{}
values are sequences where [1] is an index number that defines where in the rendering the label/value pair is
positioned and [2] is the label that will be rendered when the parameter has a value.
This indexing is used because params_t{} is not a sequence and because pairs() does not necessarily return the
'next' k/v pair.
This function spins through params_t{} and writes html for parameters that have assigned values into temp_t{}
according to the 'index' value in the associated sequance table. When parameters are missing or empty, this
function writes an empty string into the associated location in lines_t{} so that lines_t{} can be concatenated
into a string value that is returned to the calling function.
args_t is the arguments table from the template frame.
]]
local function line_items (args_t, params_t)
local lines_t = {}; -- a sequence table of rendered label/value html lines; one for each key in params_t{}
for k, v in pairs (params_t) do -- k is templat e parameter name; v is a sequence table with index and associated label
local temp_t = {} -- initialize/reinitialize for next line item
if not args_t[k] then -- if no assigned value then
lines_t[v[1]] = ''; -- set to empty string for concatenation
else
table.insert (temp_t, '<tr style="vertical-align:top;"><td style="font-weight: bold">'); -- open the line item row and cell
table.insert (temp_t, v[2]); -- add parameter's label text
table.insert (temp_t, '</td><td>'); -- close that cell and open the parameter value cell
table.insert (temp_t, _unbulleted_list (args_t[k])); -- add the parameter's value; formatted as unordered list if appropriate
table.insert (temp_t, '</td></tr>\n'); -- close that cell and this row
end
lines_t[v[1]] = table.concat (temp_t); -- concatenate and put the line item in the lines sequence table at the index position
end
return table.concat (lines_t); -- make a big string of line items and done
end
--[[--------------------------< I N F O B O X _ S H I P _ C A R E E R >----------------------------------------
implements {{Infobox ship career}}
{{#invoke:WPSHIPS utilities|infobox_ship_career}}
]]
local function infobox_ship_career (frame)
local args_t = get_args (frame); -- get a table of all parameters in the template call
local html_out_t = {}; -- html table text goes here
local error_flag = false; -- controls emission of maint category when synonymous parameters are both set
args_t['Hide header'] = args_t['Hide header'] and args_t['Hide header']:lower(); -- set to lowercase if set
error_flag = synonym_check (args_t, 'Ship stricken', 'Ship struck', error_flag); -- error if both synonymous parameters set
error_flag = synonym_check (args_t, 'Ship honours', 'Ship honors', error_flag);
if 'yes' ~= args_t['Hide header'] then -- |Hide header=yes then no header
if not ('title' == args_t['Hide header']) then -- |Hide header=title then no title bar
table.insert (html_out_t, '<tr><th colspan="2" ');
table.insert (html_out_t, styles.header_bar); -- style from WPMILHIST
table.insert (html_out_t, '>History</th></tr>\n');
end
if args_t['Ship country'] and args_t['Ship flag'] then
table.insert (html_out_t, '<tr><th height="30" colspan="2" style="background-color:#B0C4DE;text-align:left;padding-left:2px;vertical-align:middle;font-size:110%;">');
table.insert (html_out_t, _infobox_ship_flag (args_t['Ship flag']));
table.insert (html_out_t, '<span style="padding-left:1em">');
table.insert (html_out_t, args_t['Ship country']);
table.insert (html_out_t, '</span>');
table.insert (html_out_t, '</th></tr>\n');
elseif args_t['Ship country'] then
table.insert (html_out_t, '<tr><th height="30" colspan="2" style="background-color:#B0C4DE;text-align:center;vertical-align:middle;font-size:110%;">');
table.insert (html_out_t, args_t['Ship country']);
table.insert (html_out_t, '</th></tr>\n');
elseif args_t['Ship flag'] then
table.insert (html_out_t, '<tr><th height="30" colspan="2" style="background-color:#B0C4DE;padding-left:2px;">');
table.insert (html_out_t, _infobox_ship_flag (args_t['Ship flag']));
table.insert (html_out_t, '</th></tr>\n');
end
end
table.insert (html_out_t, line_items (args_t, data.infobox_career_params_t)); -- add all of the rest of the template's html
--mw.logObject (table.concat (html_out_t));
return table.concat (html_out_t); -- make a big string and done
end
--[[--------------------------< I N F O B O X _ S H I P _ C H A R A C T E R I S T I C S >----------------------
implements {{Infobox ship characteristics}}
{{#invoke:WPSHIPS utilities|infobox_ship_characteristics}}
]]
local function infobox_ship_characteristics (frame)
local args_t = get_args (frame); -- get a table of all parameters in the template call
local html_out_t = {}; -- html table text goes here
local error_flag = false; -- controls emission of maint category when synonymous parameters are both set
args_t['Hide header'] = args_t['Hide header'] and args_t['Hide header']:lower(); -- set to lowercase if set
error_flag = synonym_check (args_t, 'Ship armour', 'Ship armor', error_flag); -- error if both synonymous parameters set
error_flag = synonym_check (args_t, 'Ship draught', 'Ship draft', error_flag);
if 'yes' ~= args_t['Hide header'] then -- |Hide header=yes then no header
table.insert (html_out_t, '<tr><th colspan="2" ');
table.insert (html_out_t, styles.header_bar); -- style from WPMILHIST
table.insert (html_out_t, '>General characteristics');
if args_t['Header caption'] then
table.insert (html_out_t, ' ');
table.insert (html_out_t, args_t['Header caption']);
end
table.insert (html_out_t, '</th></tr>\n');
end
table.insert (html_out_t, line_items (args_t, data.infobox_characteristics_params_t)); -- add all of the rest of the template's html
--mw.logObject (table.concat (html_out_t));
return table.concat (html_out_t); -- make a big string and done
end
--[[--------------------------< I N F O B O X _ S H I P _ C L A S S _ O V E R V I E W >------------------------
implements {{Infobox ship class overview}}
{{#invoke:WPSHIPS utilities|infobox_ship_class_overview}}
]]
local function infobox_ship_class_overview (frame)
local args_t = get_args (frame); -- get a table of all parameters in the template call
local html_out_t = {}; -- html table text goes here
args_t['Hide header'] = args_t['Hide header'] and args_t['Hide header']:lower();
if 'yes' ~= args_t['Hide header'] then -- |Hide header=yes then no header
table.insert (html_out_t, '<tr><th colspan="2" ');
table.insert (html_out_t, styles.header_bar); -- style from WPMILHIST
table.insert (html_out_t, '>Class overview</th></tr>\n');
end
table.insert (html_out_t, line_items (args_t, data.infobox_class_overview_params_t)); -- add all of the rest of the template's html
--mw.logObject (table.concat (html_out_t));
return table.concat (html_out_t); -- make a big string and done
end
--[[--------------------------< I S _ P L I M S O L L _ F I L E N A M E >--------------------------------------
validate cite plimsoll |filename=<filename>
<filename> format is: YYvssss.pdf where
YY - least significant two digits of four-digit first year in a two-year range
30 -> 1930–1931
allowed values are all integers between and including 30–45
v - a single lowercase letter 'a' or 'b'
'a' -> volume I
'b' -> volume II
ssss - scan number begins with 0001
odd numbered scans have English headings
even numbered scans have French headings
{{#invoke:WPSHIPS utilities|is_plimsoll_filename|{{{filename}}}}}
]]
local function is_plimsoll_filename (frame)
local args_t = get_args (frame); -- get a table of all parameters in the invoke
local year, volume, scan;
if args_t[1] then -- this to avoid script errors when args_t[1] missing
year, volume, scan = args_t[1]:match ('(%d%d)(%l)(%d%d%d%d)%.[Pp][Dd][Ff]'); -- get the various parts
end
if not year then return nil end -- nil when no match so we're done
year = tonumber (year);
scan = tonumber (scan);
if (30 > year) or (45 < year) then return nil end
if not (('a' == volume) or ('b' == volume)) then return nil end
if (1 > scan) then return nil end
return true;
end
--[[--------------------------< S E T _ P L I M S O L L _ D A T E >--------------------------------------------
create two-year range from first two digits in |filename=<filename>
30 -> 1930–1931
{{#invoke:WPSHIPS utilities|set_plimsoll_date|{{{filename}}}}}
]]
local function set_plimsoll_date (frame)
local args_t = get_args (frame); -- get a table of all parameters in the invoke
if not args_t[1] then
return nil;
end
local year = args_t[1]:match ('(%d%d)%l%d%d%d%d'); -- get the intial year
year = 1900 + tonumber (year); -- make it a four-digit year
return string.format ('%d–%d', year, year + 1); -- and then add one for the second year in the range
end
--[[--------------------------< S E T _ P L I M S O L L _ S U B T I T L E >-----------------------------------1
used in {{cite plimsoll}}
return appropriate subtitle string given |subtitle=<keyword>
{{#invoke:WPSHIPS utilities|set_plimsoll_subtitle|{{{subtitle}}}}}
]]
local function set_plimsoll_subtitle (frame)
local subtitle = get_args (frame)[1]; -- get the subtitle parameter
if not subtitle then
return nil;
end
if not data.subtitles_t[subtitle] then
return ': ' .. subtitle; -- not predefined so return whatever |subtitle= holds with leading ': '
end
return ': ' .. data.subtitles_t[subtitle]; -- return predefined subtitle with leading ': '
end
--[[--------------------------< S E T _ P L I M S O L L _ U R L >----------------------------------------------
create plimsoll url from |filename=<filename>
{{#invoke:WPSHIPS utilities|set_plimsoll_url|{{{filename}}}}}
]]
local function set_plimsoll_url (frame)
local args_t = get_args (frame); -- get a table of all parameters in the invoke
if args_t[1] then
return string.format ('https://plimsoll.southampton.gov.uk/shipdata/pdfs/%s/%s',
args_t[1]:match ('(%d%d)%l%d%d%d%d'), -- get the year path portion from <filename>
args_t[1]); -- append <filename> onto the end, and done
end
end
--[[--------------------------< S C L A S S >------------------------------------------------------------------
implements {{sclass}} and {{sclass2}}
{{#invoke:WPSHIPS utilities|sclass}}
]]
local function sclass (frame)
local args_t = get_args (frame);
local parent = frame:getParent();
local template = parent:getTitle():gsub ('^Template:', ''):lower(); -- get the name of the template that called this module (includes namespace so strip that)
local class_name = args_t[1]; -- names to make it easier to understand
local ship_type = args_t[2];
local format = args_t[3];
local ship_type_dab = args_t[4];
local class_name_dab = args_t[5];
local no_cat = 'yes' == args_t['no-cat']; -- make a boolean
if not class_name then -- when omitted, abandon with error message
return error_msg_make ('missing', template, 'class name', no_cat);
end
if not ship_type then -- when omitted, abandon with error message
return error_msg_make ('missing', template, 'ship type', no_cat);
end
if format then
if tonumber (format) then -- if <format> has a value that is a number
format = tonumber (format); -- make it a number for comparisons
if 5 < format then -- is <format> outside of allowed range
return error_msg_make ('format', template, format, no_cat);
end
else -- <format> could not be converted to a number
return error_msg_make ('format', template, format, no_cat);
end
end
local out_t = {}; -- output goes here
table.insert (out_t, '[['); -- open the wikilink
table.insert (out_t, class_name); -- build the wikilink to the class article
table.insert (out_t, '-class ');
table.insert (out_t, ship_type); -- add ship type
if class_name_dab then -- when class article is disambiguated
table.insert (out_t, ' ('); -- add the disambiguator
table.insert (out_t, class_name_dab);
table.insert (out_t, ')');
end
table.insert (out_t, '|');
if 'sclass' == template:gsub ('/sandbox', '') then -- strip '/sandbox' if present; class named for a member of the class
table.insert (out_t, '\'\''); -- class name is italicized
table.insert (out_t, class_name);
table.insert (out_t, '\'\'');
else
table.insert (out_t, class_name); -- class name is a common attribute; plain text
end
if not format or (3 == format) then -- when format is omitted, same as format #3
table.insert (out_t, '-class]] [['); -- open ship-type wikilink
if ship_type_dab then -- when ship-type article is disambiguated
table.insert (out_t, ship_type); -- add ship type
table.insert (out_t, ' ('); -- and the disambiguator
table.insert (out_t, ship_type_dab);
table.insert (out_t, ')|'); -- dab is not displayed so insert a pipe and
end
table.insert (out_t, ship_type); -- add ship type
table.insert (out_t, ']]'); -- close ship-type wikilink
end
if 0 == format then -- no separate ship-type wikilink
table.insert (out_t, '-class]]');
end
if 1 == format then -- no separate ship-type wikilink
table.insert (out_t, '-class ');
table.insert (out_t, ship_type);
table.insert (out_t, ']]');
end
if 2 == format then -- ship-type is not wikilinked
table.insert (out_t, '-class]] ');
table.insert (out_t, ship_type);
end
if 4 == format then -- noun form; no ship type
table.insert (out_t, ' class]]');
end
if 5 == format then -- class name only; no '-class' annotation
table.insert (out_t, ']]');
end
return table.concat (out_t);
end
--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]
return {
cite_danfs_title = cite_danfs_title, -- external entry points for templates and invokes
hnsa = hnsa,
infobox_ship_career = infobox_ship_career,
infobox_ship_characteristics = infobox_ship_characteristics,
infobox_ship_class_overview = infobox_ship_class_overview,
infobox_ship_flag = infobox_ship_flag,
is_plimsoll_filename = is_plimsoll_filename,
navsource = navsource,
sclass = sclass,
set_plimsoll_subtitle = set_plimsoll_subtitle,
set_plimsoll_date = set_plimsoll_date,
set_plimsoll_url = set_plimsoll_url,
ship = ship, -- experiment
ship_name_format = ship_name_format,
unbulleted_list = unbulleted_list,
_infobox_ship_flag = _infobox_ship_flag, -- external entry points from another module
_ship_name_format = do_ship_name_format,
_synonym_check = synonym_check,
_unbulleted_list = _unbulleted_list,
}
c8c09d011a47c7ce86b4fd1cc3c01ec78db4e520
Module:WPSHIPS utilities/data
828
109
222
221
2023-10-01T08:32:56Z
Reverie
2
1 revision imported
Scribunto
text/plain
--[[-------------------------< S H I P P R E F I X L I S T >-----------------------------------------------
This is a list of currently supported ship prefixes.
To add to this list the form is:
['prefix'] = true,
the trailing comma is important.
]]
local ship_prefix_t =
{
['ARA'] = true, -- Armada de la República Argentina
['ARC'] = true, -- Armada Nacional de la República de Colombia
['ARM'] = true, -- Armada de la República Mexicana
['ARV'] = true, -- Armada Republica de Venezuela
['BAE'] = true, -- Buque de la Armada de Ecuador
['BAP'] = true, -- Peruvian Navy Ship
['BNS'] = true, -- Bangladesh Navy Ship
['BRP'] = true, -- Barko ng Republika ng Pilipinas
['CCGS'] = true, -- Canadian Coast Guard Ship
['CFAV'] = true, -- Canadian Forces Auxiliary Vessel
['CS'] = true, -- Cable Ship
['CSS'] = true, -- Confederate States Ship
['FGS'] = true, -- Federal German Ship
['GTS'] = true, -- Gas Turbine Ship
['HDMS'] = true, -- His/Her Danish Majesty's Ship
['HM'] = true, -- His/Her Majesty's, then used with the type of ship in military use (UK)
['HMAS'] = true, -- Her/His Majesty's Australian Ship
['HMBS'] = true, -- Her/His Majesty's Britannic Ship (also: Bahamian, Bermudian, Burmese)
['HMC'] = true, -- Her/His Majesty's Cutter
['HMCS'] = true, -- Her/His Majesty's Canadian Ship (also Colonial)
['HMHS'] = true, -- His/Her Majesty's Hospital Ship
['HMIS'] = true, -- Her/His Majesty's Indian Ship (pre republic)
['HMNZS'] = true, -- Her/His Majesty's New Zealand Ship
['HMPNGS'] = true, -- His/Her Majesty's Papua New Guinea Ship
['HMQS'] = true, -- Her/His Majesty's Queensland Ship
['HMRC'] = true, -- His/Her Majesty's Revenue Cutter
['HMS'] = true, -- Her/His Majesty's Ship
['HMSAS'] = true, -- Her/His Majesty's South African Ship
['HMT'] = true, -- Her/His Majesty's Trawler
['HMVS'] = true, -- Her/His Majesty's Victorian Ship
['HMY'] = true, -- His/Her Majesty's Yacht
['HNLMS'] = true, -- His/Her Netherlands Majesty’s Ship
['HNoMS'] = true, -- His/Her Norwegian Majesty's Ship
['HSC'] = true, -- High-Speed Craft
['HSwMS'] = true, -- His/Her Swedish Majesty's Ship
['HTMS'] = true, -- His Thai Majesty's Ship
['ICGS'] = true, -- Indian Coast Guard Ship
['IIS'] = true, -- Imperial Iranian Ship
['INS'] = true, -- Indian Naval Ship, Israeli Naval Ship
['IRIS'] = true, -- Islamic Republic of Iran Ship
['JDS'] = true, -- Japanese Defence Ship
['JS'] = true, -- Japanese Ship (post 2008)
['KA'] = true, -- Kapal Auksiliari – Auxiliary Ship (Malaysia)
['KD'] = true, -- Kapal Di-Raja — His Majesty's Ship (Malaysia)
['KM'] = true, -- Kapal Motor (Motor Ship) (Indonesia)
['KDB'] = true, -- Kapal Diraja Brunei (Royal Brunei Ship) (in Malay)
['KDM'] = true, -- Kongelige Danske Marine
['KLD'] =true, -- Kapal Layar Diraja – His Majesty's Sailing Ship (Malaysia)
['KRI'] = true, -- Kapal Republik Indonesia
['LÉ'] = true, -- Long Éireannach – Irish ship
['MF'] = true, -- Motor Ferry
['LKL'] = true, -- Lietuvos Karinis Laivas – Lithuania
['MS'] = true, -- Motor Ship
['MT'] = true, -- Motor Tanker
['MV'] = true, -- Motor Vessel
['NLV'] = true, -- Northern Lighthouse Vessel
['NMS'] = true, -- Nava Majestăţii Sale (His/Her Majesty's Ship) - used before 1945 by the Royal Romanian Navy
['NoCGV'] = true, -- Norwegian Coast Guard Vessel
['NOAAS'] = true, -- National Oceanic and Atmospheric Administration Ship
['NRP'] = true, -- Navio da República Portuguesa
['ORP'] = true, -- Okręt Rzeczypospolitej Polskiej
['PNS'] = true, -- Pakistani Naval Ship
['PS'] = true, -- Paddle Steamer
['RFA'] = true, -- Royal Fleet Auxiliary
['RMAS'] = true, -- Royal Maritime Auxiliary Service
['RMS'] = true, -- Royal Mail Ship
['RNLB'] = true, -- Royal National Lifeboat
['ROCS'] = true, -- Republic of China Ship
['ROKS'] = true, -- Republic of Korea Ship
['RPS'] = true, -- Republic of the Philippines Ship
['RRS'] = true, -- Royal Research Ship
['RS'] = true, -- Rocket Ship
['RSS'] = true, -- Republic of Singapore Ship
['RV'] = true, -- Research Vessel
['SAS'] = true, -- South African Ship
['SLNS'] = true, -- Sri Lanka Naval Ship
['SM'] = true, -- Seiner Majestät Unterseeboot
['SMS'] = true, -- Seiner Majestät Schiff
['SS'] = true, -- Screw Steamer or Steamship
['STV'] = true, -- Sail training vessel
['TCG'] = true, -- Türkiye Cumhuriyeti Gemisi
['TS'] = true, -- Training ship
['TV'] = true, -- Training vessel
['UAM'] = true, -- Unidade Auxiliar da Marinha - Navy Auxiliary Unit (Portuguese Navy non-military ships)
['USAFS'] = true, -- United States Air Force ship
['USAHS'] = true, -- United States Army Hospital Ship
['USAS'] = true, -- United States Army Ship
['USAT'] = true, -- United States Army Transport
['USAV'] = true, -- United States Army Vessel
['USC&GS'] = true, -- United States Coast and Geodetic Survey
['USC&GS'] = true, -- United States Coast and Geodetic Survey (crude work-around)
['USC&GS'] = true, -- United States Coast and Geodetic Survey (crude work-around)
['USC&GSS'] = true, -- United States Coast and Geodetic Survey Ship
['USC&GSS'] = true, -- United States Coast and Geodetic Survey Ship (crude work-around)
['USC&GSS'] = true, -- United States Coast and Geodetic Survey Ship (crude work-around)
['USCGC'] = true, -- United States Coast Guard Cutter
['USLHT'] = true, -- United State Light House Tender
['USNS'] = true, -- United States Naval Ship
['USRC'] = true, -- United States Revenue Cutter
['USS'] = true, -- United States Ship
}
--[[--------------------------< N A T I O N A L I T Y >--------------------------------------------------------
Article titles for ships in navies that do not use a standardized prefix follow the title format:
<nationality> <ship type> <name> <(disambiguator)>
This is a list of nationalities.
To add to this list the form is:
['Nationality'] = true,
the trailing comma is important. Use the adjective form for nationality, always capitalize. Please insert nationalities in alphabetical order.
]]
local nationality_t =
{
['Albanian'] = true,
['American'] = true,
['Australian'] = true,
['Belgian'] = true,
['Brazilian'] = true,
['Bulgarian'] = true,
['Chilean'] = true,
['Chinese'] = true,
['Croatian'] = true,
['Danish'] = true,
['Dominican'] = true,
['Dutch'] = true,
['East Timorese'] = true,
['Egyptian'] = true,
['English'] = true,
['Finnish'] = true,
['French'] = true,
['German'] = true,
['Greek'] = true,
['Grenadan'] = true,
['Haitian'] = true,
['Iranian'] = true,
['Irish'] = true,
['Italian'] = true,
['Japanese'] = true,
['Latvian'] = true,
['Libyan'] = true,
['Lithuanian'] = true,
['Maltese'] = true,
['Mexican'] = true,
['Nigerian'] = true,
['Ottoman'] = true,
['Peruvian'] = true,
['Portuguese'] = true,
['Romanian'] = true,
['Russian'] = true,
['Scottish'] = true,
['Slovenian'] = true,
['Soviet'] = true,
['Spanish'] = true,
['Swedish'] = true,
['Texan'] = true,
['Ukrainian'] = true,
['United States'] = true,
['Vietnamese'] = true,
['Yugoslav'] = true,
}
--[[--------------------------< S H I P T Y P E >------------------------------------------------------------
Article titles for ships in navies that do not use a standardized prefix follow the title format:
<nationality> <ship type> <name> <(disambiguator)>
Article titles for ships may or may not be naval ships may follow the title format:
<name> <(disambiguator)>
where <(disambiguator)> may be some form of ship type, hull designator or pennant number, or year. This tool will
format ship names that contain a recognized ship type in <(disambiguator)>.
This list is used to <find ship> when the article title begins with a nationality. This is important because the tool
needs to know where the <ship type> ends and <name> begins so that it can properly place the italic markup. The search
will find an exact match (including case) for ship types that are 1 to 4 words long.
This list is also used to find ship type in <(disambiguator)>. The search is whole word; use the simplest form.
For example, because 'icebreaker' is defined, that ship type is sufficient to cause the tool to properly format:
Astrolabe (icebreaker)
Krassin (1917 icebreaker)
Taymyr (nuclear icebreaker)
Searches for ship type in <(disambiguator)> are whole word. When looking for 'ship', the tool will find
Auguste (ship)
Queen of Nations (clipper ship)
but will not find:
Sibir (steamship icebreaker) – the search for 'icebreaker' will
This is a list of ship types. When adding new ship types, do not be too specific: 'aircraft carrier' but not 'light aircraft carrier'
To add to this list the form is:
['ship type'] = true,
the trailing comma is important. At the time of this writing, a ship type may be one to four words, almost always lowercase.
Please insert ship types in alphabetical order.
]]
local ship_type_t =
{
['armoured cruiser'] = true,
['aircraft carrier'] = true,
['amphibious assault ship'] = true,
['Army ship'] = true, -- should be capitalized
['auxiliary cruiser'] = true,
['auxiliary raider'] = true,
['auxiliary'] = true,
['aviso'] = true,
['barge'] = true,
['barque'] = true,
['barquentine'] = true,
['battlecruiser'] = true,
['battleship'] = true,
['boat'] = true,
['brig sloop'] = true,
['brig-sloop'] = true,
['brig'] = true,
['brigantine'] = true,
['carrack'] = true,
['clipper'] = true,
['coast defense ship'] = true,
['coastal defence ship'] = true,
['coastal defense ship'] = true,
['communications ship'] = true,
['corvette'] = true,
['cruiser'] = true,
['cutter'] = true,
['deep submergence rescue vehicle'] = true,
['destroyer leader'] = true,
['destroyer'] = true,
['dragger'] = true,
['dredge'] = true,
['East Indiaman'] = true, -- should be capitalized
['escort ship'] = true,
['escort'] = true,
['ferry'] = true,
['ferryboat'] = true,
['fireboat'] = true,
['fleet oiler'] = true,
['floating battery'] = true,
['floating crane'] = true,
['fluyt'] = true,
['food supply ship'] = true,
['freighter'] = true,
['frigate'] = true,
['galleon'] = true,
['galley'] = true,
['gunboat'] = true,
['helicopter carrier'] = true,
['hospital ship'] = true,
['hovercraft'] = true,
['hydrofoil'] = true,
['icebreaker'] = true,
['Indiaman'] = true, -- should be capitalized
['ironclad'] = true,
['ketch'] = true,
['landing ship'] = true,
['landing ship medium'] = true,
['lifeboat'] = true,
['lightship'] = true,
['log canoe'] = true,
['lugger'] = true,
['merchant cruiser'] = true,
['minehunter'] = true,
['minelayer'] = true,
['minelaying cruiser'] = true,
['minesweeper'] = true,
['missile boat'] = true,
['monitor'] = true,
['munition ship'] = true,
['naval ship'] = true,
['night fighter direction vessel'] = true,
['ocean liner'] = true,
['oiler'] = true,
['paddle steamer'] = true,
['patrol boat'] = true,
['patrol gunboat'] = true,
['patrol vessel'] = true,
['pinnace'] = true,
['pollution control vessel'] = true,
['privateer'] = true,
['protected cruiser'] = true,
['pusher'] = true,
['rescue ship'] = true,
['riverboat'] = true,
['ROV'] = true,
['sailboat'] = true,
['schooner'] = true,
['seaplane carrier'] = true,
['seaplane tender'] = true,
['ship of the line'] = true,
['ship'] = true,
['shipwreck'] = true,
['shore establishment'] = true, -- use stone frigate instead?
['showboat'] = true,
['sidewheeler'] = true,
['skipjack'] = true,
['sloop-of-war'] = true,
['sloop'] = true,
['smack'] = true,
['snagboat'] = true,
['speedboat'] = true,
['steam frigate'] = true,
['steam warship'] = true,
['steamboat'] = true,
['steamer'] = true,
['steamship'] = true,
['sternwheeler'] = true,
['stores lighter'] = true,
['submarine chaser'] = true,
['submarine rescue vehicle'] = true,
['submarine tender'] = true,
['submarine'] = true,
['submersible'] = true,
['supertanker'] = true,
['support ship'] = true,
['survey ship'] = true,
['tanker'] = true,
['target ship'] = true,
['tender'] = true,
['torpedo boat'] = true,
['torpedo gunboat'] = true,
['towboat'] = true,
['training cruiser'] = true,
['training ship'] = true,
['transport'] = true,
['trawler'] = true,
['trireme'] = true,
['tug'] = true,
['tugboat'] = true,
['vessel'] = true,
['warship'] = true,
['weather ship'] = true,
['whaler'] = true,
['whaleship'] = true,
['wherry'] = true,
['yacht'] = true,
['yawl'] = true,
}
--[[--------------------------< I N F O B O X L I N E I T E M P A R A M E T E R S >----------------------
]]
local infobox_career_params_t = { -- table of parameters that are rendered in the same way
['Ship name'] = {1, 'Name'},
['Ship namesake'] = {2, 'Namesake'},
['Ship owner'] = {3, 'Owner'},
['Ship operator'] = {4, 'Operator'},
['Ship registry'] = {5, 'Port of registry'},
['Ship route'] = {6, 'Route'},
['Ship ordered'] = {7, 'Ordered'},
['Ship awarded'] = {8, 'Awarded'},
['Ship builder'] = {9, 'Builder'},
['Ship original cost'] = {10, 'Cost'},
['Ship yard number'] = {11, 'Yard number'},
['Ship way number'] = {12, 'Way number'},
['Ship laid down'] = {13, 'Laid down'},
['Ship launched'] = {14, 'Launched'},
['Ship sponsor'] = {15, 'Sponsored by'},
['Ship christened'] = {16, 'Christened'},
['Ship completed'] = {17, 'Completed'},
['Ship acquired'] = {18, 'Acquired'},
['Ship commissioned'] = {19, 'Commissioned'},
['Ship recommissioned'] = {20, 'Recommissioned'},
['Ship decommissioned'] = {21, 'Decommissioned'},
['Ship maiden voyage'] = {22, 'Maiden voyage'},
['Ship in service'] = {23, 'In service'},
['Ship out of service'] = {24, 'Out of service'},
['Ship renamed'] = {25, 'Renamed'},
['Ship reclassified'] = {26, 'Reclassified'},
['Ship refit'] = {27, 'Refit'},
['Ship struck'] = {28, 'Stricken'},
['Ship stricken'] = {29, 'Stricken'},
['Ship reinstated'] = {30, 'Reinstated'},
['Ship homeport'] = {31, 'Homeport'},
['Ship identification'] = {32, 'Identification'},
['Ship motto'] = {33, 'Motto'},
['Ship nickname'] = {34, 'Nickname(s)'},
['Ship honours'] = {35, 'Honours and<br />awards'}, -- make these two the same index?
['Ship honors'] = {36, 'Honors and<br />awards'},
['Ship captured'] = {37, 'Captured'},
['Ship fate'] = {38, 'Fate'},
['Ship status'] = {39, 'Status'},
['Ship notes'] = {40, 'Notes'},
['Ship badge'] = {41, 'Badge'},
}
local infobox_characteristics_params_t = { -- table of parameters that are rendered in the same way
['Ship class'] = {1, 'Class and type'},
['Ship type'] = {2, 'Type'},
['Ship tonnage'] = {3, 'Tonnage'},
['Ship displacement'] = {4, 'Displacement'},
['Ship tons burthen'] = {5, 'Tons burthen'},
['Ship length'] = {6, 'Length'},
['Ship beam'] = {7, 'Beam'},
['Ship height'] = {8, 'Height'},
['Ship draught'] = {9, 'Draught'}, -- make these two the same index?
['Ship draft'] = {10, 'Draft'},
['Ship depth'] = {11, 'Depth'},
['Ship hold depth'] = {12, 'Depth of hold'},
['Ship decks'] = {13, 'Decks'},
['Ship deck clearance'] = {14, 'Deck clearance'},
['Ship ramps'] = {15, 'Ramps'},
['Ship ice class'] = {16, 'Ice class'},
['Ship power'] = {17, 'Installed power'},
['Ship propulsion'] = {18, 'Propulsion'},
['Ship sail plan'] = {19, 'Sail plan'},
['Ship speed'] = {20, 'Speed'},
['Ship range'] = {21, 'Range'},
['Ship endurance'] = {22, 'Endurance'},
['Ship test depth'] = {23, 'Test depth'},
['Ship boats'] = {24, 'Boats & landing <br /> craft carried'},
['Ship capacity'] = {25, 'Capacity'},
['Ship troops'] = {26, 'Troops'},
['Ship complement'] = {27, 'Complement'},
['Ship crew'] = {28, 'Crew'},
['Ship time to activate'] = {29, 'Time to activate'},
['Ship sensors'] = {30, 'Sensors and <br /> processing systems'},
['Ship EW'] = {31, 'Electronic warfare <br /> & decoys'},
['Ship armament'] = {32, 'Armament'},
['Ship armour'] = {33, 'Armour'}, -- make these two the same index?
['Ship armor'] = {34, 'Armor'},
['Ship aircraft'] = {35, 'Aircraft carried'},
['Ship aircraft facilities'] = {36, 'Aviation facilities'},
['Ship notes'] = {37, 'Notes'},
}
local infobox_class_overview_params_t = { -- table of parameters that are rendered in the same way
['Name'] = {1, 'Name'},
['Builders'] = {2, 'Builders'},
['Operators'] = {3, 'Operators'},
['Class before'] = {4, 'Preceded by'},
['Class after'] = {5, 'Succeeded by'},
['Subclasses'] = {6, 'Subclasses'},
['Cost'] = {7, 'Cost'},
['Built range'] = {8, 'Built'},
['In service range'] = {9, 'In service'},
['In commission range'] = {10, 'In commission'},
['Total ships planned'] = {11, 'Planned'},
['Total ships on order'] = {12, 'On order'},
['Total ships building'] = {13, 'Building'},
['Total ships completed'] = {14, 'Completed'},
['Total ships cancelled'] = {15, 'Cancelled'},
['Total ships active'] = {16, 'Active'},
['Total ships laid up'] = {17, 'Laid up'},
['Total ships lost'] = {18, 'Lost'},
['Total ships retired'] = {19, 'Retired'},
['Total ships scrapped'] = {20, 'Scrapped'},
['Total ships preserved'] = {21, 'Preserved'},
}
--[[--------------------------< C I T E P L I M S O L L >----------------------------------------------------
]]
local subtitles_t = {
['C'] = 'Chalutiers &c.', -- French headings used as subtitles; these appear on even page numbers
['F'] = 'Liste des Navires Pourvus de Machines Frigorifiques',
['NV'] = 'Navires à Voiles',
['NVM'] = 'Navires à Vapeur et à Moteurs',
['R'] = 'List of Vessels Fitted with Refrigerating Appliances', -- English headings used as subtitles; these appear on odd page numbers
['SM'] = 'Steamers & Motorships',
['SV'] = 'Sailing Vessels',
['T'] = 'Trawlers &c.',
}
local subtitles_xlate_t = {
['odd'] = { -- |filename= <page_num> is odd (en) so use French subtitle
['C'] = 'T', -- map fr keyword to en keyword
['F'] = 'R',
['NV'] = 'SV',
['NVM'] = 'SM',
},
['even'] = { -- |filename= <page_num> is even (fr) so use English subtitle
['R'] = 'F', -- map en keyword to fr keyword
['SM'] = 'NVM',
['SV'] = 'NV',
['T'] = 'C',
}
}
--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]
return {
infobox_career_params_t = infobox_career_params_t,
infobox_characteristics_params_t = infobox_characteristics_params_t,
infobox_class_overview_params_t = infobox_class_overview_params_t,
nationality_t = nationality_t,
ship_prefix_t = ship_prefix_t,
ship_type_t = ship_type_t,
subtitles_t = subtitles_t,
subtitles_xlate_t = subtitles_xlate_t,
}
b40cd8dd6cdba008208e6f9b0e1f81ae02fb2441
Template:Template
10
110
224
223
2023-10-01T08:32:57Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Template link]]
fb9a6b420e13178e581af6e7d64274cd30a79017
Template:Shipboxflag
10
111
226
225
2023-10-01T08:32:57Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{country data {{{1|}}}|shipboxflag/core|variant={{{variant|{{{2|}}}}}}}}<noinclude>{{documentation}}</noinclude>
99dee7c080f10fd8bb6dd9989c03591ec12114f0
Template:Shipboxflag/core
10
112
228
227
2023-10-01T08:32:58Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<span class="flagicon">[[File:{{{flag alias-{{{variant}}}|{{{flag alias}}}}}}|100x35px|alt=|link=]]</span><noinclude>{{documentation}}</noinclude>
be8e637c9f45a421d95f27dd17c5db2a8513813f
Template:USN flag
10
113
230
229
2023-10-01T08:32:59Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<span class="flagicon">[[File:{{#ifexpr: {{{1|9999}}} >= 1960|Flag of the United States
|{{#ifexpr: {{{1|9999}}} >= 1959|US flag 49 stars
|{{#ifexpr: {{{1|9999}}} >= 1912|US flag 48 stars
|{{#ifexpr: {{{1|9999}}} >= 1908|US flag 46 stars
|{{#ifexpr: {{{1|9999}}} >= 1896|US flag 45 stars
|{{#ifexpr: {{{1|9999}}} >= 1891|US flag 44 stars
|{{#ifexpr: {{{1|9999}}} >= 1890|US flag 43 stars
|{{#ifexpr: {{{1|9999}}} >= 1877|US flag 38 stars
|{{#ifexpr: {{{1|9999}}} >= 1867|US flag 37 stars
|{{#ifexpr: {{{1|9999}}} >= 1865|US flag 36 stars
|{{#ifexpr: {{{1|9999}}} >= 1863|US flag 35 stars
|{{#ifexpr: {{{1|9999}}} >= 1861|US flag 34 stars
|{{#ifexpr: {{{1|9999}}} >= 1859|US flag 33 stars
|{{#ifexpr: {{{1|9999}}} >= 1858|US flag 32 stars
|{{#ifexpr: {{{1|9999}}} >= 1851|US flag 31 stars
|{{#ifexpr: {{{1|9999}}} >= 1848|US flag 30 stars
|{{#ifexpr: {{{1|9999}}} >= 1847|US flag 29 stars
|{{#ifexpr: {{{1|9999}}} >= 1846|US flag 28 stars
|{{#ifexpr: {{{1|9999}}} >= 1845|US flag 27 stars
|{{#ifexpr: {{{1|9999}}} >= 1837|US flag 26 stars
|{{#ifexpr: {{{1|9999}}} >= 1836|US flag 25 stars
|{{#ifexpr: {{{1|9999}}} >= 1822|US flag 24 stars
|{{#ifexpr: {{{1|9999}}} >= 1820|US flag 23 stars
|{{#ifexpr: {{{1|9999}}} >= 1819|US flag 21 stars
|{{#ifexpr: {{{1|9999}}} >= 1818|US flag 20 stars
|{{#ifexpr: {{{1|9999}}} >= 1795|US flag 15 stars
|{{#ifexpr: {{{1|9999}}} >= 1777|US flag 13 stars
|{{#ifexpr: {{{1|9999}}} >= 1775|Flag of the United States (1776–1777)
<!--default if no param-->|Flag of the United States
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}.svg|100x35px|alt=|link=]]</span><noinclude>
{{documentation}}
</noinclude>
7772b3f5c06e3d9391d17be46b57a5db0c546371
Template:Being deleted
10
114
232
231
2023-10-01T08:33:00Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#switch:{{{_demospace|{{NAMESPACE}}}}}|Template|Module={{Mbox
| type = delete
| image = none
| text = '''This {{#if:{{{module|}}}|module|template}} is currently being {{#if:{{{merge|}}}|merged with [[{{{merge}}}]]|[[Wikipedia:Deletion policy|deleted]]}}.'''<br />This {{#if:{{{module|}}}|module|template}} is being {{#if:{{{merge|}}}|merged with another {{#if:{{{module|}}}|module|template}}|removed from the pages on which it is currently used}}, after which it will be {{#if:{{{merge|}}}|redirected or deleted|deleted}}. '''Please check [[Wikipedia:Templates for discussion/Holding cell]] for any additional instructions'''. {{#if:{{{merge|}}}||Please do not use it on any additional pages, but do not remove it from pages if it is under [[Wikipedia:Deletion review|deletion review]].}} The decision to {{#if:{{{merge|}}}|merge|delete}} this template was made following [[Wikipedia:Templates for discussion/Log/{{Date|{{{date|{{{1}}}}}}|ymd}}#{{#if:{{{template|{{{2|}}}}}}|{{{template|{{{2}}}}}}|{{#if:{{{module|}}}|{{{module}}}|Template:{{PAGENAME}}}}}}|this discussion initiated on {{Date|{{YMD to ISO|{{{date|{{{1}}}}}}}}|dmy}}]] at [[Wikipedia:Templates for discussion|Templates for discussion]].<small>{{#if:{{{merge|}}}|<br/>'''Note''': Please review this template's instructions at [[Wikipedia:Templates for discussion/Holding cell]] before proceeding with any type of merging.|<span class="sysop-show"><br/>'''[[Wikipedia:Administrators|Administrators]]''': Please review this {{#if:{{{module|}}}|module|template}}'s instructions at [[Wikipedia:Templates for discussion/Holding cell]] before proceeding with any action.</span>}}</small>
}}{{#if:{{{nocat|<noinclude>yes</noinclude>}}}||[[Category:Wikipedia templates currently being merged or deleted]]}}
|{{#switch:{{lc:{{{type}}}}}
<!-- Sidebar version, used if type=sidebar-->
|infobox|box|sidebar= <div class="boilerplate metadata plainlinks" id="tfd" style="background-color: transparent; padding: 0; font-size:xx-small; color:#000000; text-align: center; position: relative; float: right; border-bottom:1px solid #AAAAAA; width: {{if empty|{{{width|}}}|27em}}">‹ The {{#if:{{{module|}}}|[[Help:Module|module]]|[[Help:Template|template]]}} below {{#if:{{{module|{{{template|{{{2|}}}}}}}}}|([[{{{module|{{{template|{{{2}}}}}}}}}|{{PAGENAME:{{{module|{{{template|{{{2}}}}}}}}}}}]])}} is being {{#if:{{{merge|}}}|merged|deleted}}. See [[Wikipedia:Templates for discussion/Log/{{Date|{{{date|{{{1}}}}}}|ymd}}#{{#if:1|{{{module|{{{template|{{{2|}}}}}}}}}}}|templates for discussion]] for the discussion that led to this result. ›</div>
<!-- Default version, used in all other cases -->
|#default = <div class="boilerplate metadata plainlinks" id="tfd" style="background-color: transparent; padding: 0; font-size:xx-small; color:#000000; text-align: center; border-bottom:1px solid #AAAAAA;">‹ The {{#if:{{{module|}}}|[[Help:Module|module]]|[[Help:Template|template]]}} below {{#if:{{{module|{{{template|{{{2|}}}}}}}}}|([[{{{module|{{{template|{{{2}}}}}}}}}|{{PAGENAME:{{{module|{{{template|{{{2}}}}}}}}}}}]])}} is being {{#if:{{{merge|}}}|merged|deleted}}. See [[Wikipedia:Templates for discussion/Log/{{Date|{{{date|{{{1}}}}}}|ymd}}#{{#if:1|{{{module|{{{template|{{{2|}}}}}}}}}}}|templates for discussion]] for the discussion that led to this result. ›</div>
}}
}}<!-- integrate with Twinkle CSD module --><span id="delete-reason" style="display:none">{{urlencode:[[WP:CSD#G6|G6]]: [[Wikipedia:Templates for discussion/Log/{{Date|{{{date|{{{1}}}}}}|ymd}}#{{#if:{{{template|{{{2|}}}}}}|{{{template|{{{2}}}}}}|{{#if:{{{module|}}}|{{{module}}}|Template:{{PAGENAME}}}}}}]]}}</span><span id="delete-criterion" style="display:none">{{uc:{{{criterion}}}}}</span><noinclude>
{{Documentation}}
</noinclude>
50afbcb02152b5f6e6eee9e05c74e21afceefd90
Template:YMD to ISO
10
115
234
233
2023-10-01T08:33:01Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:YMD to ISO|main|{{{1|}}}}}<noinclude>
{{Documentation}}
</noinclude>
30d1e18baa22a6e88743a6f71bbc166ceced5ddb
Module:YMD to ISO
828
116
236
235
2023-10-01T08:33:01Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p = {}
local function month_number(month_name)
local months_full = {january=1, february=2, march=3, april=4, may=5, june=6, july=7, august=8, september=9, october=10, november=11, december=12}
local months_abbr = {jan=1, feb=2, mar=3, apr=4, may=5, jun=6, jul=7, aug=8, sep=9, sept=9, oct=10, nov=11, dec=12}
local month_lc, _ = string.gsub(string.lower(month_name),'%.','',1)
local month_num = months_full[month_lc] or months_abbr[month_lc] or 0
return month_num
end
local function days_in_month(month_num,year)
-- modified from code in Module:Citation/CS1/Date_validation
local days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
local month_length
if month_num == 2 then -- February: 28 days, unless leap year
month_length = 28
if year <= 1582 then -- Julian calendar before Oct 1582
if (year%4) == 0 then
month_length = 29 -- if leap year, then 29 days
end
else -- Gregorian calendar since Oct 1582
if ( (year%4)==0 and ((year%100)~=0 or (year%400)==0) ) then
month_length = 29 -- if leap year, then 29 days
end
end
else -- not February, get number of days for month
month_length = days[month_num]
end
return month_length
end
local function zero_pad(string)
if string.len(string) == 1 then
return '0' .. string
else
return string
end
end
function p.main(frame)
if frame.args[1] == nil then
return '' -- first argument is missing
end
local arg1, _ = string.gsub(mw.text.trim(frame.args[1]),'_',' ')
return p._main(arg1)
end
function p._main(arg1)
if arg1 == '' then
return '' -- first argument is empty
end
if not arg1:match('^%d%d%d%d %a%a%a%a?%.?%a?%a?%a?%a?%a?%a? *%d%d?$') then
return arg1 -- invalid date pattern
end
local year, month_name, day = string.match(arg1, '^(%d%d%d%d) *(%a%a%a%a?%.?%a?%a?%a?%a?%a?%a?) *(%d%d?)$')
if month_number(month_name) == 0 then
return arg1 -- invalid month name or abbreviation
end
if tonumber(day) < 1 or tonumber(day) > days_in_month(month_number(month_name),tonumber(year)) then
return arg1 -- invalid day number for given month
end
return year .. '-' .. zero_pad(tostring(month_number(month_name))) .. '-' .. zero_pad(day)
end
return p
a9f87bfe223afec859d2f3de909e6682d2334db4
Template:Infobox ship begin/shared doc
10
117
238
237
2023-10-01T08:33:04Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{Documentation subpage|override=shared doc|a group of templates}}{{#ifeq:{{BASEPAGENAME}}|Infobox ship begin|{{lua|Module:WPSHIPS utilities}}
: ''N.B.: {{tl|Infobox ship begin}} contains code that can automatically style a variety of ship and ship-class article titles. It adds a [[WP:DISPLAYTITLE|DISPLAYTITLE]] with italics unless'' <code>{{!}}display title=none</code> ''is specified. For details see: the infobox usage guide § [[Template:Infobox ship begin/Usage guide#Title styling|Title styling]].''}}
This ship infobox supports a very large number of fields, including some specialty fields that will rarely be used. Some fields simply don't make sense in some cases. Some different sets of code have been prepared using only the most common fields. Select the most appropriate set below and copy and paste the entire code to the top of a ship article, then fill in as many fields as possible. Empty fields should generally be kept so that a future editor can fill them in unless they make no sense for the ship in question.
The "Full" code contains every field the template supports. If you want, you can copy one of the simplified sets of code and add a few fields from the "Full" code.
If you have ideas for improvements or would like to add brand new fields to these templates, please post on [[Template talk:Infobox ship begin]] to discuss the changes and how they should be implemented.
=== Usage ===
==== Code for individual ships ====
For infoboxes of individual ships, please copy the appropriate example for the type of ship:
{{collapse top |bg=#d0e5f5 |title=Warships (except submarines). {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- warships except submarines -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship owner=
|Ship namesake=
|Ship ordered=
|Ship builder=
|Ship laid down=
|Ship launched=
|Ship acquired=
|Ship commissioned=
|Ship decommissioned=
|Ship in service=
|Ship out of service=
|Ship stricken=
|Ship reinstated=
|Ship honours=
|Ship honors=
|Ship fate=
|Ship status=
|Ship notes=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship propulsion=
|Ship speed=
|Ship range=
|Ship complement=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship armour=
|Ship armor=
|Ship aircraft=
|Ship aircraft facilities=
|Ship notes=
}}
|}
</syntaxhighlight>
{{collapse bottom}}<!-- end of warships except submarines -->
{{collapse top |bg=#d0e5f5 |title=Submarines. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- submarines -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship namesake=
|Ship ordered=
|Ship builder=
|Ship laid down=
|Ship launched=
|Ship acquired=
|Ship commissioned=
|Ship decommissioned=
|Ship in service=
|Ship out of service=
|Ship stricken=
|Ship reinstated=
|Ship fate=
|Ship status=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship propulsion=
|Ship speed=
|Ship range=
|Ship endurance=
|Ship test depth=
|Ship complement=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of submarines -->
{{collapse top |bg=#d0e5f5 |title=Age of sail. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- age of sail -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship owner=
|Ship ordered=
|Ship builder=
|Ship original cost=
|Ship laid down=
|Ship launched=
|Ship acquired=
|Ship commissioned=
|Ship decommissioned=
|Ship in service=
|Ship out of service=
|Ship renamed=
|Ship stricken=
|Ship reinstated=
|Ship honours=
|Ship honors=
|Ship captured=
|Ship fate=
|Ship status=
|Ship notes=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship tons burthen=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship hold depth=
|Ship propulsion=
|Ship sail plan=
|Ship complement=
|Ship armament=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of Age of Sail -->
{{collapse top |bg=#d0e5f5 |title=Commercial vessels. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- commercial vessels -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship name=
|Ship owner=
|Ship operator=
|Ship registry=
|Ship route=
|Ship ordered=
|Ship builder=
|Ship original cost=
|Ship yard number=
|Ship way number=
|Ship laid down=
|Ship launched=
|Ship completed=
|Ship christened=
|Ship acquired=
|Ship maiden voyage=
|Ship in service=
|Ship out of service=
|Ship identification=
|Ship fate=
|Ship status=
|Ship notes=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship type=
|Ship tonnage=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship height=
|Ship draught=
|Ship draft=
|Ship depth=
|Ship decks=
|Ship deck clearance=
|Ship ramps=
|Ship ice class=
|Ship sail plan=
|Ship power=
|Ship propulsion=
|Ship speed=
|Ship capacity=
|Ship crew=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of commercial vessels -->
<br />
If none of the above fit, you may use this full setup:
{{collapse top |bg=#d0e5f5 |title=Full code for individual ships. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- full code -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship career
|Hide header=
|Ship country=
|Ship flag=
|Ship name=
|Ship namesake=
|Ship owner=
|Ship operator=
|Ship registry=
|Ship route=
|Ship ordered=
|Ship awarded=
|Ship builder=
|Ship original cost=
|Ship yard number=
|Ship way number=
|Ship laid down=
|Ship launched=
|Ship sponsor=
|Ship christened=
|Ship completed=
|Ship acquired=
|Ship commissioned=
|Ship recommissioned=
|Ship decommissioned=
|Ship maiden voyage=
|Ship in service=
|Ship out of service=
|Ship renamed=
|Ship reclassified=
|Ship refit=
|Ship stricken=
|Ship reinstated=
|Ship homeport=
|Ship identification=
|Ship motto=
|Ship nickname=
|Ship honours=
|Ship honors=
|Ship captured=
|Ship fate=
|Ship status=
|Ship notes=
|Ship badge=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship type=
|Ship tonnage=
|Ship displacement=
|Ship tons burthen=
|Ship length=
|Ship beam=
|Ship height=
|Ship draught=
|Ship draft=
|Ship depth=
|Ship hold depth=
|Ship decks=
|Ship deck clearance=
|Ship ramps=
|Ship ice class=
|Ship power=
|Ship propulsion=
|Ship sail plan=
|Ship speed=
|Ship range=
|Ship endurance=
|Ship test depth=
|Ship boats=
|Ship capacity=
|Ship troops=
|Ship complement=
|Ship crew=
|Ship time to activate=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship armour=
|Ship armor=
|Ship aircraft=
|Ship aircraft facilities=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of all options setup -->
==== Code for ship classes ====
For infoboxes of ship classes, please copy the appropriate example for the type of ship class:
{{collapse top |bg=#CCCCFF |title=Warship classes (except submarines). {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- warship classes -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Built range=
|In commission range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship type=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship propulsion=
|Ship speed=
|Ship range=
|Ship complement=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship armour=
|Ship armor=
|Ship aircraft=
|Ship aircraft facilities=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of warships classes -->
{{collapse top |bg=#CCCCFF |title=Submarine classes. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- submarine classes -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Built range=
|In commission range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship type=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship propulsion=
|Ship speed=
|Ship range=
|Ship endurance=
|Ship test depth=
|Ship complement=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of submarine classes -->
{{collapse top |bg=#CCCCFF |title=Age of sail classes. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- age of sail classes -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Built range=
|In commission range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship type=
|Ship tons burthen=
|Ship length=
|Ship beam=
|Ship draught=
|Ship draft=
|Ship hold depth=
|Ship propulsion=
|Ship sail plan=
|Ship complement=
|Ship armament=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of age of sail classes -->
{{collapse top |bg=#CCCCFF |title=Commercial vessel classes. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- commercial vessel classes -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Built range=
|In service range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship type=
|Ship tonnage=
|Ship displacement=
|Ship length=
|Ship beam=
|Ship height=
|Ship draught=
|Ship draft=
|Ship depth=
|Ship decks=
|Ship deck clearance=
|Ship ramps=
|Ship ice class=
|Ship sail plan=
|Ship power=
|Ship propulsion=
|Ship speed=
|Ship capacity=
|Ship crew=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of commercial vessel classes -->
<br>
If none of the above fit, you may use this full setup:
{{collapse top |bg=#CCCCFF |title=Full code for ship classes. {{nobold|{{small|Select show to expand.}}}}}}
<syntaxhighlight lang="wikitext">
{|{{Infobox ship begin <!-- full code -->
|infobox caption= <!-- keywords: yes, nodab; or caption text -->
|display title= <!-- keywords: none, ital; or article title with markup -->
|sclass= <!-- keyword: 2 -->
}}
{{Infobox ship image
|Ship image=
|Ship image size=
|Ship caption=
|image alt=
}}
{{Infobox ship class overview
|Name=
|Builders=
|Operators=
|Class before=
|Class after=
|Subclasses=
|Cost=
|Built range=
|In service range=
|In commission range=
|Total ships planned=
|Total ships on order=
|Total ships building=
|Total ships completed=
|Total ships cancelled=
|Total ships active=
|Total ships laid up=
|Total ships lost=
|Total ships retired=
|Total ships scrapped=
|Total ships preserved=
}}
{{Infobox ship characteristics
|Hide header=
|Header caption=
|Ship class=
|Ship type=
|Ship tonnage=
|Ship displacement=
|Ship tons burthen=
|Ship length=
|Ship beam=
|Ship height=
|Ship draught=
|Ship draft=
|Ship depth=
|Ship hold depth=
|Ship decks=
|Ship deck clearance=
|Ship ramps=
|Ship ice class=
|Ship power=
|Ship propulsion=
|Ship sail plan=
|Ship speed=
|Ship range=
|Ship endurance=
|Ship test depth=
|Ship boats=
|Ship capacity=
|Ship troops=
|Ship complement=
|Ship crew=
|Ship time to activate=
|Ship sensors=
|Ship EW=
|Ship armament=
|Ship armour=
|Ship armor=
|Ship aircraft=
|Ship aircraft facilities=
|Ship notes=
}}
|}</syntaxhighlight>
{{collapse bottom}}<!-- end of full code -->
=== Parameters ===
{{Further information|Template:Infobox ship begin/Usage guide}}
Most fields are self-explanatory, but here are some tips (see the [[Template:Infobox ship begin/Usage guide|usage guide]] for a complete explanation of all parameter fields):
#'''Ship image''' If your article does not have an image in this field, the ship will automatically be listed at the hidden category [[:Category:Ship infoboxes without an image]]. Editors can use the category to easily see a list of infoboxes where no image is attached and work to find pictures.
#'''Ship caption''' and '''image alt''', the caption and alt for the ship's picture, should be left blank if no extra information about the picture is available; don't just fill in the ship's name.
#'''Ship country''' is necessary when a ship served under multiple countries, but not really necessary otherwise.
#'''Ship class''' should include both the class and the type of ship. For example, [[Balao class submarine|''Balao''-class]] [[diesel-electric]] [[submarine]] provides complete information. It can be replaced with '''Ship type''', which displays as "Type:", for ships that aren't members of a class.
#'''Ship name''' is necessary when a ship served under multiple names, but not really necessary otherwise.
#'''Ship fate''' and '''Ship status''' generally shouldn't both be filled in. Whichever one sounds most appropriate for the situation should be filled in. Use Ship fate when the ship sank or was scrapped, and use Ship status when the ship is active, kept in reserve, or currently a museum.
#'''Ship displacement''' and '''Ship tonnage''' are not the same thing. [[Displacement (fluid)|Displacement]] is the mass of a ship in a particular condition, like when it's fully loaded for battle. It is generally used for military vessels. [[Tonnage]] is a measurement of the cargo capacity of a vessel and isn't exactly correlated with weight: a ship of a particular tonnage will have a different mass depending on whether it's full of grain or iron. Entries in either parameter need to specifically identify the units in which they are being measured, such as long tons, metric tons or tonnes (unacceptable in articles using American English, use metric tons) or gross register tons or whatever. If possible, use templates such as {{Template|GT}}, {{Template|NetT}} and {{Template|DWT}}.
==== Alternative spellings ====
Some fields provide alternative spellings and should never both be filled in:
# "Ship honors" and "Ship honours"
# "Ship draft" and "Ship draught"
# "Ship armor" and "Ship armour"
===Removing extra fields===
It's generally a good idea not to remove fields, because another editor might be able to provide the information later. However, in the case of mutually exclusive fields, like "Ship armor" and "Ship armour", the unused field can be removed if desired. Also, if a section is repeated (to show multiple periods in commission, for example), fields that are inappropriate to duplicate can be removed if desired. Keep in mind that a ship from the Age of Sail would not need the fields for aircraft or electronic warfare instruments and conversely an aircraft carrier would not need the fields for a sail plan. A surface ship would not require fields for submarines etc.
=== Special capabilities ===
==== Repeating sections ====
This infobox allows you to repeat sections. To repeat, just make a copy of the section to be repeated. You can repeat the Image, Career, or Characteristics sections. Here is an example, with extra fields removed for clarity:
{|{{Infobox ship begin |infobox caption=USS ''Bang'' (SS-385)}}
{{Infobox ship image
| Ship image=Uss bang.jpg
| Ship caption=
}}
{{Infobox ship career
| Ship country=U.S.
| Ship flag={{USN flag|1972}}
| Ship name=USS ''Bang'' (SS-385)
| Ship laid down=30 April 1943
| Ship launched=30 August 1943
| Ship commissioned=4 December 1943
| Ship decommissioned=1 October 1972
| Ship struck=18 November 1974
| Ship fate=Transferred to Spain, 1 October 1972
}}
{{Infobox ship career
| Ship country=Spain
| Ship flag={{shipboxflag|Spain}}
| Ship name=SPS ''Cosme Garcia'' (S34)
| Ship acquired=1 October 1972
| Ship fate=scrapped 1983
}}
{{Infobox ship characteristics
| Header caption=
| Ship displacement=*1,526 tons surfaced
*2,391 tons
| Ship length={{convert|311|ft|8|in|m|2|abbr=on}}
| Ship beam={{convert|27|ft|3|in|m|2|abbr=on}}
| Ship complement=66
}}
|}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
| Ship image=Uss bang.jpg
| Ship caption=
}}
{{Infobox ship career
| Ship country=US
| Ship flag={{USN flag|1972}}
| Ship name=USS ''Bang'' (SS-385)
| Ship laid down=30 April 1943
| Ship launched=30 August 1943
| Ship commissioned=4 December 1943
| Ship decommissioned=1 October 1972
| Ship struck=18 November 1974
| Ship fate=Transferred to Spain, 1 October 1972
}}
{{Infobox ship career
| Ship country=Spain
| Ship flag={{shipboxflag|Spain}}
| Ship name=SPS ''Cosme Garcia'' (S34)
| Ship acquired=1 October 1972
| Ship fate=scrapped 1983
}}
{{Infobox ship characteristics
| Header caption=
| Ship displacement=*1,526 tons surfaced
*2,391 tons
| Ship length=311 ft 8 in (95 m)
| Ship beam=27 ft 3 in (8.3 m)
| Ship complement=66
}}
|}</syntaxhighlight>
{{-}}
==== Hiding section headers ====
It is possible to hide the headers for the Career and General Characteristics sections, in order to repeat fields. For example, a ship might have been commissioned, decommissioned, recommissioned, and decommissioned again. To have the second commission and decommission dates, use additional a second Infobox ship career template with its header hidden, like this:
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
| Ship image=USS Wisconsin (BB-64) underway at sea, circa 1988-1991 (NH 97206-KN).jpg
| Ship caption=USS ''Wisconsin'' at sea, circa 1990
| image alt=USS ''Wisconsin'' at sea, circa 1990
}}
{{Infobox ship career
| Hide header=
| Ship caption=US
| Ship flag={{USN flag|1992}}
| Ship laid down=25 January 1941
| Ship launched=7 December 1943
| Ship commissioned=16 April 1944
| Ship decommissioned=1 July 1948
}}
{{Infobox ship career
| Hide header=yes
| Ship recommissioned=3 March 1951
| Ship decommissioned=8 March 1958
}}
{{Infobox ship career
| Hide header=yes
| Ship recommissioned=1 August 1986
| Ship decommissioned=30 September 1991
| Ship struck=17 March 2006
| Ship fate=[[Museum ship]]
}}
{{Infobox ship characteristics
| Hide header=
| Header caption=(1943)
| Ship displacement=45,000 tons
| Ship length=887.2 ft (270 m)
| Ship beam=108.2 ft (33 m)
| Ship draft=28.9 ft (8.8 m)
| Ship speed=33 knots (61 km/h)
| Ship complement=1,921 officers and men
| Ship armament=big guns
}}
|}
<syntaxhighlight lang="wikitext" style="overflow:auto">
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
| Ship image=USS Wisconsin (BB-64) underway at sea, circa 1988-1991 (NH 97206-KN).jpg
| Ship caption=USS ''Wisconsin'' at sea, circa 1990
| image alt=USS ''Wisconsin'' at sea, circa 1990
}}
{{Infobox ship career
| Hide header=
| Ship caption=(US)
| Ship flag={{USN flag|1992}}
| Ship laid down=25 January 1941
| Ship launched=7 December 1943
| Ship commissioned=16 April 1944
| Ship decommissioned=1 July 1948
}}
{{Infobox ship career
| Hide header=yes
| Ship recommissioned=3 March 1951
| Ship decommissioned=8 March 1958
}}
{{Infobox ship career
| Hide header=yes
| Ship recommissioned=1 August 1986
| Ship decommissioned=30 September 1991
| Ship struck=17 March 2006
| Ship fate=[[Museum ship]]
}}
{{Infobox ship characteristics
| Hide header=
| Header caption=(1943)
| Ship displacement=45,000 tons
| Ship length=887.2 ft (270 m)
| Ship beam=108.2 ft (33 m)
| Ship draft=28.9 ft (8.8 m)
| Ship speed=33 knots (61 km/h)
| Ship complement=1,921 officers and men
| Ship armament=big guns
}}
|}</syntaxhighlight>
{{clear}}
==== Header captions ====
The General Characteristics section can be given a caption using the '''Header caption''' field. See the USS Wisconsin example above, which has a header caption of (1943) to indicate that the characteristics provided are as of 1943.
{{-}}
=== Custom fields ===
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
|Ship image=Uss west virginia bb.jpg
|Ship caption=''West Virginia'' in San Francisco Bay, circa 1934.
|image alt=''West Virginia'' in San Francisco Bay, circa 1934.
}}
{{Infobox ship career
| Hide header=
| Ship caption=US
| Ship flag={{USN flag|1947}}
| Ship ordered=5 December 1916
| Ship laid down=12 April 1920
| Ship launched=17 November 1921
| Ship commissioned=1 December 1923
}}
|-
| Sunk:
|7 December 1941
|-
|Raised:
|17 May 1942
{{Infobox ship career
| Hide header=yes
| Ship decommissioned=9 January 1947
| Ship fate=sold for scrap
| Ship struck=1 March 1959
| Ship nickname="Wee Vee"
}}
{{Infobox ship characteristics
| Hide header=
| Ship displacement=33,590 tons
| Ship length=624 ft (190 m)
| Ship beam=97.3 ft (29.6 m)
| Ship draft=30.5 ft (9.3 m)
| Ship speed=21.0 knots (39 km/h)
| Ship complement=1,407 officers and men
| Ship armament=big guns
}}
|}
It is possible to add custom fields to the infobox using standard [[Help:Table|Wiki table syntax]]. This is not encouraged, because infoboxes are intended to standardize the appearance of ship articles, but it can be done if needed. See the below example, where "Sunk:" and "Raised:" fields are added to the ship's career:
<syntaxhighlight lang="wikitext" style="overflow:auto">
{|{{Infobox ship begin |infobox caption=}}
{{Infobox ship image
|Ship image=Uss west virginia bb.jpg
|Ship caption=''West Virginia'' in San Francisco Bay, circa 1934.
|image alt=''West Virginia'' in San Francisco Bay, circa 1934.
}}
{{Infobox ship career
| Hide header=
| Ship caption=US
| Ship flag={{USN flag|1947}}
| Ship ordered=5 December 1916
| Ship laid down=12 April 1920
| Ship launched=17 November 1921
| Ship commissioned=1 December 1923
}}
|-
| Sunk:
|7 December 1941
|-
|Raised:
|17 May 1942
{{Infobox ship career
| Hide header=yes
| Ship decommissioned=9 January 1947
| Ship fate=sold for scrap
| Ship struck=1 March 1959
| Ship nickname="Wee Vee"
}}
{{Infobox ship characteristics
| Hide header=
| Ship displacement=33,590 tons
| Ship length=624 ft (190 m)
| Ship beam=97.3 ft (29.6 m)
| Ship draft=30.5 ft (9.3 m)
| Ship speed=21.0 knots (39 km/h)
| Ship complement=1,407 officers and men
| Ship armament=big guns
}}
|}</syntaxhighlight><!--
--><includeonly>{{Sandbox other||
{{#ifeq:{{SUBPAGENAME}}|doc||
{{#ifeq:{{NAMESPACE}}|{{NS:10}}|
<!-- ADD CATEGORIES BELOW THIS LINE -->
[[Category:Water transport infobox templates|Ship table]]
[[Category:Military ship infobox templates|Ship table]]
[[Category:Ship templates|Ship table]]
}}
}}
}}</includeonly>
e0286ecc255848ee0ede5c58fcde20b2f7c9d30e
Template:Infobox ship career/doc
10
118
240
239
2023-10-01T08:33:06Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{Documentation subpage}}
{{lua|Module:WPSHIPS utilities}}
This template is part of the WikiProject Ships ship infobox. It adds a Career box to the infobox. Each section, except Infobox Ship Begin, can be repeated as necessary to support multiple careers, multiple sets of characteristics, etc. The header of the Career box can be hidden by setting its "Hide header=yes". This allows you to repeat certain fields by adding a second Career box with a hidden header.{{Infobox ship begin/shared doc}}
===TemplateData===
{{TemplateData header}}
<templatedata>
{
"description": "This template is part of the WikiProject Ships ship infobox. It adds a Career box to the infobox. Each section, except Infobox Ship Begin, can be repeated as necessary to support multiple careers, multiple sets of characteristics, etc. The header of the Career box can be hidden by setting its \"Hide header=yes\". This allows you to repeat certain fields by adding a second Career box with a hidden header.",
"params": {
"Hide header": {
"description": "If you need to repeat fields by using multiple copies of the \"Career\" subtemplate, enter \"Yes\" in this field to prevent display of the blue bar at the top of the second template. At least one \"Career\" header should be left visible.",
"type": "boolean"
},
"Ship country": {
"description": "The nation a ship is associated with; either the nation a warship belongs to, or the nation of registry for civilian ships. However, in case of civilian ships flying flags of convenience, this field should not be used. The country is placed in the infobox header. Do not use this field to indicate ranges.",
"type": "string"
},
"Ship flag": {
"description": "The ensign (maritime flag) associated with a ship",
"type": "string"
},
"Ship class": {
"description": "If the ship belongs to a recognized ship class, use this field to identify the class. The field displays as \"class & type\", so the type should be added here as well.",
"type": "string"
},
"Ship name": {
"description": "The name of the ship",
"type": "string"
},
"Ship namesake": {
"description": "If the ship's name originates from a particular person, location, event, or object, it may be added here. However, descriptions longer than a few words (e.g. a person's name or \"Finnish for \"potato\"\") should be placed in the article body.",
"type": "string"
},
"Ship owner": {
"description": "The company or organisation that owns the vessel. When multiple entries are made in this field, include year ranges. Leave this field blank for warships, as the combination of the |Ship country= and |Ship flag= fields will generally be enough for readers to identify ownership.",
"type": "string"
},
"Ship operator": {
"description": "The company or organisation that operates or runs the ship. If the owner of the vessel is also the operator, this field may be left empty. If it is necessary to mention the charterer of the ship in the infobox, use a separate custom field for that.",
"type": "string"
},
"Ship registry": {
"description": "The nation and port of registry for a civilian vessel. This is generally found painted on the ship's stern. The nation of registry should be expressed as text, not as a flag symbol. A flag symbol may be used in addition, but only if such usage meets Wikipedia:Manual of Style/Icons. When multiple entries are made in this field, include year ranges",
"type": "string"
},
"Ship route": {
"description": "If a civilian or merchant vessel has a long-term (multiple years +) association with a particular voyage path or route. Do not use this field for modern cruise ships, as their routes change on a regular basis.",
"type": "string"
},
"Ship ordered": {
"description": "The date that the ship was ordered from the shipbuilder.",
"type": "string"
},
"Ship awarded": {
"description": "For United States Navy vessels, the date that the contract to build the ships was signed/approved.",
"type": "string"
},
"Ship builder": {
"description": "The shipyard or other construction facility where the vessel was built. Usually, only the building company is listed here. The location of the shipyard may also be added, but avoid too much detail: anything more than a single 'location link' can be discussed in the body of the article or referred to with a link (for example [[Vickers-Armstrongs]], [[Barrow-in-Furness]] or [[BAE Systems Australia]], [[Williamstown, Victoria]], but not [[Scotts Shipbuilding and Engineering Company]], [[Greenock]], [[Scotland]], [[United Kingdom]])",
"type": "string"
},
"Ship original cost": {
"description": "The financial cost of building the ship, usually at the time of construction and using the currency of either the orderer or the builder. If other values are used (e.g. conversions), they should be specified and, if necessary, further discussed in the article",
"type": "string"
},
"Ship yard number": {
"description": "An identifying number assigned for the ship by the builder during construction",
"type": "string"
},
"Ship way number": {
"description": "If the particular slipway where a ship was built has been identified with a number, it may be added here. Rarely used for modern vessels.",
"type": "string"
},
"Ship laid down": {
"description": "The date on which the keel was laid down onto the slipway by the builder. For most ships, this is the point where construction of the vessel starts, and is usually accompanied by ceremony. Although modular construction techniques mean that fabrication of modern vessels can start prior to this, the first time a module is placed on the slipway or building dock is still recognised as the date a ship is laid down.",
"type": "string"
},
"Ship launched": {
"description": "The date a ship is launched, floated out, or other circumstance where the completed hull enters the water. Construction is not normally completed by this date. Take care not to confuse it with dates recognising the ship's entry into service (such as commissioning or maiden voyage)",
"type": "string"
},
"Ship sponsor": {
"description": "The individual (usually a woman and sometimes referred to as a \"launching lady\") who does the whole ceremonial \"smash-the-bottle,-launch-the-ship\" thing as part of the launching ceremony. This is not to be used for any companies or organisations providing sponsorship of a vessel in exchange for advertising or naming rights.",
"type": "string"
},
"Ship christened": {
"description": "The date of the ceremony in which the ship formally and/or ceremonially receives her name (see Ship naming and launching). Only use this field if the naming/christening happened at a separate point in time to either the launching or commissioning ceremonies.",
"type": "string"
},
"Ship completed": {
"description": "The date construction work finished",
"type": "string"
},
"Ship acquired": {
"description": "The date of delivery by the shipbuilder to the owner or operator. If it is the same as the completion date, this field may be left empty. Alternatively, if the ship changes ownership and multiple, separate \"Career\" subtemplates are being used, the date the new owner/operator came into possession of the ship. Do not use this method if the change of ownership is being handled through multiple entries in the |Ship owner= field",
"type": "string"
},
"Ship commissioned": {
"description": "The date a warship was commissioned into naval service.\nDo not use for civilian merchant vessels",
"type": "string"
},
"Ship recommissioned": {
"description": "If a naval vessel was decommissioned from service, then reactivated, use this field to add the new commissioning date\nUsed best with multiple copies of the \"Career\" subtemplate (|Ship commissioned= and |Ship decommissioned= fields in the first template, |Ship recommissioned= and |Ship decommissioned= in the second).\nDo not use for civilian merchant vessels",
"type": "string"
},
"Ship decommissioned": {
"description": "The date a warship was decommissioned or paid off from naval service.\nDo not use this field if events related to the ship's fate (such as loss in action) mean the ship was never formally decommissioned.\nDo not use for civilian merchant vessels.",
"type": "string"
},
"Ship maiden voyage": {
"description": "The dates and locations of the start and end of the ship's maiden voyage: the first recognised voyage in full service, usually carrying passengers or cargo.\nThe transfer of a completed ship from the shipyard to its owner is not normally recognised as a maiden voyage; this is part of the sea trial or shakedown phase, which ensures the ship is working as built.\nMost commonly used for civilian passenger-carrying vessels",
"type": "string"
},
"Ship in service": {
"description": "The date a civilian vessel began operations.\nAlternatively, this may be treated as a date range indicating the start and end points of a ship's career. If being used in this manner, ignore the |Ship out of service= field.",
"type": "string"
},
"Ship out of service": {
"description": "The date a civilian vessel ceased operations.\nIf the |Ship in service= field is being used with a date range instead of a set date, do not use this field.",
"type": "string"
},
"Ship renamed": {
"description": "If the ship changes names, the new names and corresponding dates may be listed here.\nIf multiple names are listed in the |Ship name= field, ignore this field.",
"type": "string"
},
"Ship reclassified": {
"description": "When a warship's classification is altered, the date and new classification may be listed here",
"type": "string"
},
"Ship refit": {
"description": "If the ship underwent a major modification or refit, the start and end dates may be listed here.",
"type": "string"
},
"Ship struck": {
"description": "When a ship is removed from an official register (such as the United States Navy's Naval Vessel Register), the date of removal (or striking) from the register should be listed here.\nThis field does not include collisions, groundings or attacks a ship has experienced.",
"type": "string"
},
"Ship reinstated": {
"description": "If, after a ship has been stricken from a register, she is returned to service and is re-listed on that register, the date of reinstatement should be listed here\nUsed best with multiple copies of the \"Career\" subtemplate.",
"type": "string"
},
"Ship homeport": {
"description": "The home port of the vessel (if different from |Ship registry=): For civilian ships, this will be the primary port from which the ship operates (i.e. for cruise ships, the port in which cruises start and end). Port of registry (the one painted on the stern) should be listed in |Ship registry=. For warships, this will be the ship's assigned naval base.\n\nWhen multiple entries are made in this field, include year ranges.\nFor ships that change their home port on a regular basis (more than once every couple of years), consider ignoring this field and elaborating in the body of the article",
"type": "string"
},
"Ship identification": {
"description": "Any identification numbers or codes for the vessel are listed here. This may include IMO numbers (use {{IMO number}}), MMSI numbers (use {{MMSI}}), Maritime call sign, and pennant/hull numbers (although consider not using the field for hull numbers if these are indicated in the lead sentence of the article).",
"type": "string"
},
"Ship motto": {
"description": "If the ship has a motto, it should be listed here. Wrap non-English mottos in {{lang}} templates followed by the English translation",
"type": "string"
},
"Ship nickname": {
"description": "If the ship has any nicknames, they should be listed here.\nTake care to ensure these are sourced (either in the infobox, or in the body of the article), and consider adding related context and/or circumstances to the article itself.",
"type": "string"
},
"Ship honors": {
"aliases": [
"Ship honours"
],
"description": "Used to list any battle honours, battle stars, unit citations, or other unit awards awarded to the ship for her service.\nDo not list awards given to individuals, even if the award was for service aboard the vessel. Mention these awards in the relevant part of the ship's history.\nAvoid listing annual capability or competition awards (such as the Battle Effectiveness Award or the Gloucester Cup) to avoid bloat. Battle honours of a previous ship with the same name might be appropriate.\nBritish English (honours) and American English (honors) alternatives are provided; delete whichever is inappropriate.",
"type": "string"
},
"Ship captured": {
"description": "When the ship falls into enemy hands, and whose hands they are.\nKeep it brief by only indicating the capturing nation and the date (i.e. \"Antarctica, 30 February 2012\"). Detail relating to the capture should be in the article.\nFollow up with a new \"Career\" subtemplate to discuss the ship's career with her captor.",
"type": "string"
},
"Ship fate": {
"description": "Used to indicate that a ship is no longer operational, and will not return to service in the future. This is usually when something pretty permanent happens to the ship, like sinking or scrapping. Rule of thumb: \"Is the ship permanently below the surface, or in pieces?\"\nOnly list the event and the date it occurred (for example: \"Sank following collision on 10 February 1964\", or \"Sold for scrap in 1975\". Details such as location, cause, etc. should be discussed in the article.\nIn the majority of cases, |Ship status= and |Ship fate= are mutually exclusive. Unlike other redundant fields, leave |Ship fate= in the article, as the ship's life will end one day.",
"type": "string"
},
"Ship status": {
"description": "Used to indicate that a ship is currently in service, or has been removed from service but is available for future use or preserved in some form. Rule of thumb: \"Is the ship above the water and intact?\"\nFor active ships, consider using {{Ship in active service}} or other means to indicate the last known date (generally year) the ship was active. However, if the ship is expected to remain in service in the near future and its decommissioning will not likely go unnoticed, simply |Ship in service= should be enough.\nFor inactive ships, indicate briefly what the ship is 'doing' (laid up, in reserve, preserved as museum ship, awaiting disposal, etc.) and, if deemed necessary, where it is moored.\nIn the majority of cases, |Ship status= and |Ship fate= are mutually exclusive. If the |Ship fate= field is used, delete this field.",
"type": "string"
},
"Ship notes": {
"description": "Any other important information not covered by the other infobox fields, but not important enough for a custom field.\nThis field should not be used for citations/references: either the citations should be attached to the specific entry, or the infobox should be treated as part of the lead section, with the citations attached to the information in the body of the article.",
"type": "string"
},
"Ship badge": {
"description": "An image or description of any naval heraldry, such as the ship's badge or crest, may be added here",
"type": "string"
}
},
"format": "block"
}
</templatedata>
84f7cefd1f90de1f890ed206e0ed507663087f1c
Template:Auto italic title
10
119
242
241
2023-10-01T08:42:48Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{ombox
| type = notice
| text = This {{{2|infobox}}} should [[Wikipedia:Article titles#Italics and other formatting|italicize the article title]] automatically. If this is not required, add {{para|{{#if:{{{1|}}}|{{{1}}}|italic title}}|{{#if:{{{3|}}}|{{{3}}}|no}}}} to the list of parameters. {{#if: {{{short|}}} | | If this is required but the title is not being italicized, try {{para|{{#if:{{{1|}}}|{{{1}}}|italic title}}|force}}.}}
}}<noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage, interwikis to Wikidata, not here -->
</noinclude>
6dc78a3d3de470bea8dc684b3278f5806fe0f5c3
Template:Infobox ship begin/doc
10
120
244
243
2023-10-01T08:42:49Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{Documentation subpage}}
{{High-use}}
{{Auto italic title|1=display title|2=template|3=none|short=y}}
{{Infobox ship begin/shared doc}}
===TemplateData===
{{TemplateData header}}
<templatedata>
{
"description": "Start template for Infobox ship (see template documentation), includes optional caption for the infobox",
"params": {
"Infobox caption": {
"label": "infobox caption",
"type": "string",
"required": false,
"description": "Caption for the infobox. Set to yes to use formatted article title; set to nodab to use formatted article title without parenthetical disambiguator; all other values become infobox caption."
},
"showerrs": {},
"sclass": {},
"display title": {}
},
"format": "block"
}
</templatedata>
=== See also ===
* {{tlx|WikiProject Ships|needs-infobox{{=}}y}}
<!--IMPORTANT:
{{Infobox ship begin/shared doc}} adds some categories. You should probably edit that page.
-->
c5ed959526f629f3bd96d5d912374751dcff1ff4
Template:Infobox ship image/doc
10
121
246
245
2023-10-01T08:42:50Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{Documentation subpage}}
{{Lua|Module:InfoboxImage|Module:Check for unknown parameters}}
This template is part of the new WikiProject Ships ship infobox. It adds a picture and caption to the infobox. Each section, except Infobox Ship Begin, can be repeated as necessary to support multiple careers, multiple sets of characteristics, etc.
{{Infobox ship begin/shared doc}}
===TemplateData===
{{TemplateData header}}
<templatedata>
{
"description": "Used to add an image to ship articles. Used with {{Infobox ship begin}}. If your article does not have an image in this field, the ship will automatically be listed at the hidden category [[Category:Ship infoboxes without an image]]. Editors can use the category to easily see a list of infoboxes where no image is attached and work to find pictures.",
"paramOrder": [
"image",
"image alt",
"image size",
"caption"
],
"params": {
"image": {
"aliases": [
"Ship image"
],
"label": "Image name",
"type": "string",
"required": true,
"description": "Name of the image to be displayed. Simple name is enough. Full image syntax is accepted... for now."
},
"image size": {
"aliases": [
"Ship image size"
],
"label": "Image size",
"type": "string",
"description": "Size of the image in CSS syntax. e.g. 300px. Optional. Use wisely; Wikipedia policy requires deviations from standard size to remain minimum. Ignored if a full image syntax with size is added to |image parameter.",
"default": "300px"
},
"image alt": {
"label": "Image alternative text",
"type": "string",
"description": "Alternative text for the image, shown to those who are unable to see the image."
},
"caption": {
"aliases": [
"Ship caption"
],
"label": "Caption",
"type": "string",
"description": "caption text shown beneath the image."
}
},
"format": "block"
}
</templatedata>
<includeonly>
[[tl:Suleras:Infobox Ship Image]]
[[tr:Şablon:Gemi bilgi kutusu resim]]
</includeonly>
e124f05235bce2d6d1b386a0b287764eb16fca24
Template:Infobox ship characteristics/doc
10
122
248
247
2023-10-01T08:42:51Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{Documentation subpage}}
{{lua|Module:WPSHIPS utilities}}
This template is part of the WikiProject Ships ship infobox. It adds a Characteristics section to the infobox. Each section, except Infobox Ship Begin, can be repeated as necessary to support multiple careers, multiple sets of characteristics, etc. The header of the Characteristics box can be hidden by setting its "Hide header=yes". This allows you to repeat certain fields by adding a second Characteristics box with a hidden header. Also, additional text can be added to the Characteristics box with "Header caption=".
{{Infobox ship begin/shared doc}}
===TemplateData===
{{TemplateData header}}
<templatedata>
{
"description": "Ship characteristics, to be used with {{Infobox ship begin}}",
"params": {
"Hide header": {
"label": "Hide header",
"type": "string",
"required": false
},
"Header caption": {
"label": "Header caption",
"type": "string",
"required": false
},
"Ship class": {
"label": "Ship class",
"type": "string",
"required": false
},
"Ship type": {
"label": "Ship type",
"type": "string",
"required": false
},
"Ship tonnage": {
"label": "Ship tonnage",
"type": "string",
"required": false
},
"Ship displacement": {
"label": "Ship displacement",
"type": "string",
"required": false
},
"Ship tons burthen": {
"label": "Ship tons burthen",
"type": "string",
"required": false
},
"Ship length": {
"label": "Ship length",
"type": "string",
"required": false
},
"Ship beam": {
"label": "Ship beam",
"type": "string",
"required": false
},
"Ship height": {
"label": "Ship height",
"type": "string",
"required": false
},
"Ship draught": {
"label": "Ship draught",
"type": "string",
"required": false
},
"Ship draft": {
"label": "Ship draft",
"type": "string",
"required": false
},
"Ship depth": {
"label": "Ship depth",
"type": "string",
"required": false
},
"Ship hold depth": {
"label": "Ship hold depth",
"type": "string",
"required": false
},
"Ship decks": {
"label": "Ship decks",
"type": "string",
"required": false
},
"Ship deck clearance": {
"label": "Ship deck clearance",
"type": "string",
"required": false
},
"Ship ramps": {
"label": "Ship ramps",
"type": "string",
"required": false
},
"Ship ice class": {
"label": "Ship ice class",
"type": "string",
"required": false
},
"Ship power": {
"label": "Ship power",
"type": "string",
"required": false
},
"Ship propulsion": {
"label": "Ship propulsion",
"type": "string",
"required": false
},
"Ship sail plan": {
"label": "Ship sail plan",
"type": "string",
"required": false
},
"Ship speed": {
"label": "Ship speed",
"type": "string",
"required": false
},
"Ship range": {
"label": "Ship range",
"type": "string",
"required": false
},
"Ship endurance": {
"label": "Ship endurance",
"type": "string",
"required": false
},
"Ship test depth": {
"label": "Ship test depth",
"type": "string",
"required": false
},
"Ship boats": {
"label": "Ship boats",
"type": "string",
"required": false
},
"Ship capacity": {
"label": "Ship capacity",
"type": "string",
"required": false
},
"Ship troops": {
"label": "Ship troops",
"type": "string",
"required": false
},
"Ship complement": {
"label": "Ship complement",
"type": "string",
"required": false
},
"Ship crew": {
"label": "Ship crew",
"type": "string",
"required": false
},
"Ship time to activate": {
"label": "Ship time to activate",
"type": "string",
"required": false
},
"Ship sensors": {
"label": "Ship sensors",
"type": "string",
"required": false
},
"Ship EW": {
"label": "Ship EW",
"type": "string",
"required": false
},
"Ship armament": {
"label": "Ship armament",
"type": "string",
"required": false
},
"Ship armour": {
"label": "Ship armour",
"type": "string",
"required": false
},
"Ship armor": {
"label": "Ship armor",
"type": "string",
"required": false
},
"Ship aircraft": {
"label": "Ship aircraft",
"type": "string",
"required": false
},
"Ship aircraft facilities": {
"label": "Ship aircraft facilities",
"type": "string",
"required": false
},
"Ship motto": {
"label": "Ship motto",
"type": "string",
"required": false
},
"Ship nickname": {
"label": "Ship nickname",
"type": "string",
"required": false
},
"Ship honours": {
"label": "Ship honours",
"type": "string",
"required": false
},
"Ship honors": {
"label": "Ship honors",
"type": "string",
"required": false
},
"Ship notes": {
"label": "Ship notes",
"type": "string",
"required": false
},
"Ship badge": {
"label": "Ship badge",
"type": "string",
"required": false
}
},
"format": "block"
}
</templatedata>
<includeonly>
[[tr:Şablon:Gemi bilgi kutusu karakteristik]]
</includeonly>
49163fbd152574ea5450b24d9e543721bea2ddd1
Template:Invoke
10
123
250
249
2023-10-01T08:52:38Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#invoke:LuaCall|invoke}}</includeonly><noinclude>{{Doc}}</noinclude>
e7254069f4bce95ca8e4bb7ee0797d16c30b3555
Template:Nowrap
10
124
252
251
2023-10-01T08:52:38Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<span class="nowrap">{{{1}}}</span><noinclude>
{{documentation}}
<!-- Categories go on the /doc page; interwikis go to Wikidata. -->
</noinclude>
5d0dc6b6d89b37f4356242404f46138a4017f015
Module:Redirect
828
125
254
253
2023-10-01T08:52:40Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module provides functions for getting the target of a redirect page.
local p = {}
-- Gets a mw.title object, using pcall to avoid generating script errors if we
-- are over the expensive function count limit (among other possible causes).
local function getTitle(...)
local success, titleObj = pcall(mw.title.new, ...)
if success then
return titleObj
else
return nil
end
end
-- Gets the name of a page that a redirect leads to, or nil if it isn't a
-- redirect.
function p.getTargetFromText(text)
local target = string.match(
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)%]%]"
) or string.match(
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)|[^%[%]]-%]%]"
)
return target and mw.uri.decode(target, 'PATH')
end
-- Gets the target of a redirect. If the page specified is not a redirect,
-- returns nil.
function p.getTarget(page, fulltext)
-- Get the title object. Both page names and title objects are allowed
-- as input.
local titleObj
if type(page) == 'string' or type(page) == 'number' then
titleObj = getTitle(page)
elseif type(page) == 'table' and type(page.getContent) == 'function' then
titleObj = page
else
error(string.format(
"bad argument #1 to 'getTarget'"
.. " (string, number, or title object expected, got %s)",
type(page)
), 2)
end
if not titleObj then
return nil
end
local targetTitle = titleObj.redirectTarget
if targetTitle then
if fulltext then
return targetTitle.fullText
else
return targetTitle.prefixedText
end
else
return nil
end
end
--[[
-- Given a single page name determines what page it redirects to and returns the
-- target page name, or the passed page name when not a redirect. The passed
-- page name can be given as plain text or as a page link.
--
-- Returns page name as plain text, or when the bracket parameter is given, as a
-- page link. Returns an error message when page does not exist or the redirect
-- target cannot be determined for some reason.
--]]
function p.luaMain(rname, bracket, fulltext)
if type(rname) ~= "string" or not rname:find("%S") then
return nil
end
bracket = bracket and "[[%s]]" or "%s"
rname = rname:match("%[%[(.+)%]%]") or rname
local target = p.getTarget(rname, fulltext)
local ret = target or rname
ret = getTitle(ret)
if ret then
if fulltext then
ret = ret.fullText
else
ret = ret.prefixedText
end
return bracket:format(ret)
else
return nil
end
end
-- Provides access to the luaMain function from wikitext.
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})
return p.luaMain(args[1], args.bracket, args.fulltext) or ''
end
-- Returns true if the specified page is a redirect, and false otherwise.
function p.luaIsRedirect(page)
local titleObj = getTitle(page)
if not titleObj then
return false
end
if titleObj.isRedirect then
return true
else
return false
end
end
-- Provides access to the luaIsRedirect function from wikitext, returning 'yes'
-- if the specified page is a redirect, and the blank string otherwise.
function p.isRedirect(frame)
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})
if p.luaIsRedirect(args[1]) then
return 'yes'
else
return ''
end
end
return p
a224c45940343d66f49a78b0a39b2045e2c45d20
Module:Unsubst
828
126
256
255
2023-10-01T08:52:41Z
Reverie
2
1 revision imported
Scribunto
text/plain
local checkType = require('libraryUtil').checkType
local p = {}
local BODY_PARAM = '$B'
local specialParams = {
['$params'] = 'parameter list',
['$aliases'] = 'parameter aliases',
['$flags'] = 'flags',
['$B'] = 'template content',
['$template-name'] = 'template invocation name override',
}
function p.main(frame, body)
-- If we are substing, this function returns a template invocation, and if
-- not, it returns the template body. The template body can be specified in
-- the body parameter, or in the template parameter defined in the
-- BODY_PARAM variable. This function can be called from Lua or from
-- #invoke.
-- Return the template body if we aren't substing.
if not mw.isSubsting() then
if body ~= nil then
return body
elseif frame.args[BODY_PARAM] ~= nil then
return frame.args[BODY_PARAM]
else
error(string.format(
"no template content specified (use parameter '%s' from #invoke)",
BODY_PARAM
), 2)
end
end
-- Sanity check for the frame object.
if type(frame) ~= 'table'
or type(frame.getParent) ~= 'function'
or not frame:getParent()
then
error(
"argument #1 to 'main' must be a frame object with a parent " ..
"frame available",
2
)
end
-- Find the invocation name.
local mTemplateInvocation = require('Module:Template invocation')
local name
if frame.args['$template-name'] and '' ~= frame.args['$template-name'] then
name = frame.args['$template-name'] -- override whatever the template name is with this name
else
name = mTemplateInvocation.name(frame:getParent():getTitle())
end
-- Combine passed args with passed defaults
local args = {}
if string.find( ','..(frame.args['$flags'] or '')..',', ',%s*override%s*,' ) then
for k, v in pairs( frame:getParent().args ) do
args[k] = v
end
for k, v in pairs( frame.args ) do
if not specialParams[k] then
if v == '__DATE__' then
v = mw.getContentLanguage():formatDate( 'F Y' )
end
args[k] = v
end
end
else
for k, v in pairs( frame.args ) do
if not specialParams[k] then
if v == '__DATE__' then
v = mw.getContentLanguage():formatDate( 'F Y' )
end
args[k] = v
end
end
for k, v in pairs( frame:getParent().args ) do
args[k] = v
end
end
-- Trim parameters, if not specified otherwise
if not string.find( ','..(frame.args['$flags'] or '')..',', ',%s*keep%-whitespace%s*,' ) then
for k, v in pairs( args ) do args[k] = mw.ustring.match(v, '^%s*(.*)%s*$') or '' end
end
-- Pull information from parameter aliases
local aliases = {}
if frame.args['$aliases'] then
local list = mw.text.split( frame.args['$aliases'], '%s*,%s*' )
for k, v in ipairs( list ) do
local tmp = mw.text.split( v, '%s*>%s*' )
aliases[tonumber(mw.ustring.match(tmp[1], '^[1-9][0-9]*$')) or tmp[1]] = ((tonumber(mw.ustring.match(tmp[2], '^[1-9][0-9]*$'))) or tmp[2])
end
end
for k, v in pairs( aliases ) do
if args[k] and ( not args[v] or args[v] == '' ) then
args[v] = args[k]
end
args[k] = nil
end
-- Remove empty parameters, if specified
if string.find( ','..(frame.args['$flags'] or '')..',', ',%s*remove%-empty%s*,' ) then
local tmp = 0
for k, v in ipairs( args ) do
if v ~= '' or ( args[k+1] and args[k+1] ~= '' ) or ( args[k+2] and args[k+2] ~= '' ) then
tmp = k
else
break
end
end
for k, v in pairs( args ) do
if v == '' then
if not (type(k) == 'number' and k < tmp) then args[k] = nil end
end
end
end
-- Order parameters
if frame.args['$params'] then
local params, tmp = mw.text.split( frame.args['$params'], '%s*,%s*' ), {}
for k, v in ipairs(params) do
v = tonumber(mw.ustring.match(v, '^[1-9][0-9]*$')) or v
if args[v] then tmp[v], args[v] = args[v], nil end
end
for k, v in pairs(args) do tmp[k], args[k] = args[k], nil end
args = tmp
end
return mTemplateInvocation.invocation(name, args)
end
p[''] = p.main -- For backwards compatibility
return p
7f01ffc8aa2ac4a4772f14c12e0b77e384ecabb6
Template:Section link
10
127
258
257
2023-10-01T08:52:47Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#invoke:Section link|main}}<noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
</noinclude>
8d047e5845f8a9b74a4655b5dd79ca7595a8f88b
Module:Section link
828
128
260
259
2023-10-01T08:52:48Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module implements {{section link}}.
require('strict');
local checkType = require('libraryUtil').checkType
local p = {}
local function makeSectionLink(page, section, display)
display = display or section
page = page or ''
-- MediaWiki doesn't allow these in `page`, so only need to do for `section`
if type(section) == 'string' then
section = string.gsub(section, "{", "{")
section = string.gsub(section, "}", "}")
end
return string.format('[[%s#%s|%s]]', page, section, display)
end
local function normalizeTitle(title)
title = mw.ustring.gsub(mw.ustring.gsub(title, "'", ""), '"', '')
title = mw.ustring.gsub(title, "%b<>", "")
return mw.title.new(title).prefixedText
end
function p._main(page, sections, options, title)
-- Validate input.
checkType('_main', 1, page, 'string', true)
checkType('_main', 3, options, 'table', true)
if sections == nil then
sections = {}
elseif type(sections) == 'string' then
sections = {sections}
elseif type(sections) ~= 'table' then
error(string.format(
"type error in argument #2 to '_main' " ..
"(string, table or nil expected, got %s)",
type(sections)
), 2)
end
options = options or {}
title = title or mw.title.getCurrentTitle()
-- Deal with blank page names elegantly
if page and not page:find('%S') then
page = nil
options.nopage = true
end
-- Make the link(s).
local isShowingPage = not options.nopage
if #sections <= 1 then
local linkPage = page or ''
local section = sections[1] or 'Notes'
local display = '§ ' .. section
if isShowingPage then
page = page or title.prefixedText
if options.display and options.display ~= '' then
if normalizeTitle(options.display) == normalizeTitle(page) then
display = options.display .. ' ' .. display
else
error(string.format(
'Display title "%s" was ignored since it is ' ..
"not equivalent to the page's actual title",
options.display
), 0)
end
else
display = page .. ' ' .. display
end
end
return makeSectionLink(linkPage, section, display)
else
-- Multiple sections. First, make a list of the links to display.
local ret = {}
for i, section in ipairs(sections) do
ret[i] = makeSectionLink(page, section)
end
-- Assemble the list of links into a string with mw.text.listToText.
-- We use the default separator for mw.text.listToText, but a custom
-- conjunction. There is also a special case conjunction if we only
-- have two links.
local conjunction
if #sections == 2 then
conjunction = '​ and '
else
conjunction = ', and '
end
ret = mw.text.listToText(ret, nil, conjunction)
-- Add the intro text.
local intro = '§§ '
if isShowingPage then
intro = (page or title.prefixedText) .. ' ' .. intro
end
ret = intro .. ret
return ret
end
end
function p.main(frame)
local yesno = require('Module:Yesno')
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Section link',
valueFunc = function (key, value)
value = value:match('^%s*(.-)%s*$') -- Trim whitespace
-- Allow blank first parameters, as the wikitext template does this.
if value ~= '' or key == 1 then
return value
end
end
})
for k, v in pairs(args) do -- replace underscores in the positional parameter values
if 'number' == type(k) then
if not yesno (args['keep-underscores']) then -- unless |keep-underscores=yes
args[k] = mw.uri.decode (v, 'WIKI'); -- percent-decode; replace underscores with space characters
else
args[k] = mw.uri.decode (v, 'PATH'); -- percent-decode; retain underscores
end
end
end
-- Sort the arguments.
local page
local sections, options = {}, {}
for k, v in pairs(args) do
if k == 1 then
-- Doing this in the loop because of a bug in [[Module:Arguments]]
-- when using pairs with deleted arguments.
page = mw.text.decode(v, true)
elseif type(k) == 'number' then
sections[k] = v
else
options[k] = v
end
end
options.nopage = yesno (options.nopage); -- make boolean
-- Extract section from page, if present
if page then
local p, s = page:match('^(.-)#(.*)$')
if p then page, sections[1] = p, s end
end
-- Compress the sections array.
local function compressArray(t)
local nums, ret = {}, {}
for num in pairs(t) do
nums[#nums + 1] = num
end
table.sort(nums)
for i, num in ipairs(nums) do
ret[i] = t[num]
end
return ret
end
sections = compressArray(sections)
return p._main(page, sections, options)
end
return p
5cc61d43dc601ca43e9472500fc5cd09ca7cea44
Template:No redirect
10
129
262
261
2023-10-01T08:52:49Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{safesubst:<noinclude/>#if: {{safesubst:<noinclude/>#invoke:Redirect|isRedirect|{{{1}}}}}
| <span class="plainlinks">[{{safesubst:<noinclude/>fullurl:{{{1}}}|redirect=no}} {{{2|{{{1}}}}}}]</span>
| {{safesubst:<noinclude/>#if:{{{2|}}}|[[:{{safesubst:<noinclude/>FULLPAGENAME:{{{1}}}}}|{{{2}}}]]|[[:{{safesubst:<noinclude/>FULLPAGENAME:{{{1}}}}}]]}}
}}<noinclude>
{{documentation}}
</noinclude>
1760035b1bed54ee08b810208ed3551b812dfe13
Template:Tag
10
130
264
263
2023-10-01T08:52:51Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<code class="{{#ifeq:{{{wrap|}}}|yes|wrap|nowrap}}" style="{{#ifeq:{{{style|}}}|plain|border:none;background:transparent;|{{{style|}}}}}"><!--
Opening tag
-->{{#switch:{{{2|pair}}}
|c|close =
|e|empty|s|single|v|void
|o|open
|p|pair = <{{#if:{{{link|}}}|[[HTML element#{{{1|tag}}}|{{{1|tag}}}]]|{{{1|tag}}}}}{{#if:{{{params|{{{attribs|}}}}}}| {{{params|{{{attribs}}}}}}}}
}}<!--
Content between tags
-->{{#switch:{{{2|pair}}}
|c|close = {{{content|}}}
|e|empty|s|single|v|void =  />
|o|open = >{{{content|}}}
|p|pair = {{#ifeq:{{{1|tag}}}|!--||>}}{{{content|...}}}
}}<!--
Closing tag
-->{{#switch:{{{2|pair}}}
|e|empty|s|single|v|void
|o|open =
|c|close
|p|pair = {{#ifeq:{{{1|tag}}}|!--|-->|</{{{1|tag}}}>}}
}}<!--
--></code><noinclude>
{{Documentation}}
</noinclude>
eae208bc1612c834de697fa3ee9b343966cf8602
Template:Always substitute
10
131
266
265
2023-10-01T08:52:51Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{{{{|safesubst:}}}#invoke:Unsubst|main|$B=
{{Ombox
| name = Subst only
| type = notice
| text = '''This template {{#switch:{{{yesnomaybe|}}}|may=may be [[Help:Substitution|substituted]]'''|never=should ''not'' be [[Help:Substitution|substituted]]'''||#default=should always be [[Help:Substitution|substituted]]''' (i.e., use <!--
-->{{{actualtemplate|{{template other|{{Tlsp|{{#switch:{{SUBPAGENAME}}|doc|sandbox={{BASEPAGENAME}}|{{PAGENAME}}}}}}|{{Tlsu|{{FULLPAGENAME}}}}}}}}})}}. <!--
-->{{#if:{{yesno|{{{auto|no}}}}} |Any accidental transclusions will be automatically substituted by a bot.{{{1|}}}{{#switch:{{SUBPAGENAME}}|doc|sandbox=|[[Category:Wikipedia templates to be automatically substituted]]}}}} <!--
-->{{#if:{{{alt|}}} |For transcluding, use {{Tl|{{{alt|}}}}} instead.}}
}}{{#switch:{{SUBPAGENAME}}|doc|sandbox=|[[Category:Wikipedia substituted templates]]}}}}<noinclude>{{Documentation}}</noinclude>
8e567c153f4f9a6a329e76bf6a71e8a216e87919
Template:Tlxs
10
132
268
267
2023-10-01T08:52:52Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Template link expanded with subst]]
{{Redirect category shell|
{{R from move}}
}}
74e095f26cae0cd68518f2f66d74e948a7861c79
Template:Template link expanded with subst
10
133
270
269
2023-10-01T08:52:52Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{#Invoke:Template link general|main|code=on|subst=on}}<noinclude>
{{Documentation|1=Template:Tlg/doc
|content = {{tlg/doc|tlxs}}
}}
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
9b2ef0a8c882c336902f1d61dcff3658528c2210
Module:Shortcut
828
134
272
271
2023-10-01T08:52:52Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module implements {{shortcut}}.
-- Set constants
local CONFIG_MODULE = 'Module:Shortcut/config'
-- Load required modules
local checkType = require('libraryUtil').checkType
local yesno = require('Module:Yesno')
local p = {}
local function message(msg, ...)
return mw.message.newRawMessage(msg, ...):plain()
end
local function makeCategoryLink(cat)
return string.format('[[%s:%s]]', mw.site.namespaces[14].name, cat)
end
function p._main(shortcuts, options, frame, cfg)
checkType('_main', 1, shortcuts, 'table')
checkType('_main', 2, options, 'table', true)
options = options or {}
frame = frame or mw.getCurrentFrame()
cfg = cfg or mw.loadData(CONFIG_MODULE)
local templateMode = options.template and yesno(options.template)
local redirectMode = options.redirect and yesno(options.redirect)
local isCategorized = not options.category or yesno(options.category) ~= false
-- Validate shortcuts
for i, shortcut in ipairs(shortcuts) do
if type(shortcut) ~= 'string' or #shortcut < 1 then
error(message(cfg['invalid-shortcut-error'], i), 2)
end
end
-- Make the list items. These are the shortcuts plus any extra lines such
-- as options.msg.
local listItems = {}
for i, shortcut in ipairs(shortcuts) do
local templatePath, prefix
if templateMode then
-- Namespace detection
local titleObj = mw.title.new(shortcut, 10)
if titleObj.namespace == 10 then
templatePath = titleObj.fullText
else
templatePath = shortcut
end
prefix = options['pre' .. i] or options.pre or ''
end
if options.target and yesno(options.target) then
listItems[i] = templateMode
and string.format("{{%s[[%s|%s]]}}", prefix, templatePath, shortcut)
or string.format("[[%s]]", shortcut)
else
listItems[i] = frame:expandTemplate{
title = 'No redirect',
args = templateMode and {templatePath, shortcut} or {shortcut, shortcut}
}
if templateMode then
listItems[i] = string.format("{{%s%s}}", prefix, listItems[i])
end
end
end
table.insert(listItems, options.msg)
-- Return an error if we have nothing to display
if #listItems < 1 then
local msg = cfg['no-content-error']
msg = string.format('<strong class="error">%s</strong>', msg)
if isCategorized and cfg['no-content-error-category'] then
msg = msg .. makeCategoryLink(cfg['no-content-error-category'])
end
return msg
end
local root = mw.html.create()
root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = 'Module:Shortcut/styles.css'} })
-- Anchors
local anchorDiv = root
:tag('div')
:addClass('module-shortcutanchordiv')
for i, shortcut in ipairs(shortcuts) do
local anchor = mw.uri.anchorEncode(shortcut)
anchorDiv:tag('span'):attr('id', anchor)
end
-- Shortcut heading
local shortcutHeading
do
local nShortcuts = #shortcuts
if nShortcuts > 0 then
local headingMsg = options['shortcut-heading'] or
redirectMode and cfg['redirect-heading'] or
cfg['shortcut-heading']
shortcutHeading = message(headingMsg, nShortcuts)
shortcutHeading = frame:preprocess(shortcutHeading)
end
end
-- Shortcut box
local shortcutList = root
:tag('div')
:addClass('module-shortcutboxplain noprint')
:attr('role', 'note')
if options.float and options.float:lower() == 'left' then
shortcutList:addClass('module-shortcutboxleft')
end
if options.clear and options.clear ~= '' then
shortcutList:css('clear', options.clear)
end
if shortcutHeading then
shortcutList
:tag('div')
:addClass('module-shortcutlist')
:wikitext(shortcutHeading)
end
local ubl = require('Module:List').unbulleted(listItems)
shortcutList:wikitext(ubl)
return tostring(root)
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
-- Separate shortcuts from options
local shortcuts, options = {}, {}
for k, v in pairs(args) do
if type(k) == 'number' then
shortcuts[k] = v
else
options[k] = v
end
end
-- Compress the shortcut array, which may contain nils.
local function compressArray(t)
local nums, ret = {}, {}
for k in pairs(t) do
nums[#nums + 1] = k
end
table.sort(nums)
for i, num in ipairs(nums) do
ret[i] = t[num]
end
return ret
end
shortcuts = compressArray(shortcuts)
return p._main(shortcuts, options, frame)
end
return p
03fd46a265e549852a9ed3d3a9249b247d84cb4f
Module:Shortcut/config
828
135
274
273
2023-10-01T08:52:53Z
Reverie
2
1 revision imported
Scribunto
text/plain
-- This module holds configuration data for [[Module:Shortcut]].
return {
-- The heading at the top of the shortcut box. It accepts the following parameter:
-- $1 - the total number of shortcuts. (required)
['shortcut-heading'] = '[[Wikipedia:Shortcut|{{PLURAL:$1|Shortcut|Shortcuts}}]]',
-- The heading when |redirect=yes is given. It accepts the following parameter:
-- $1 - the total number of shortcuts. (required)
['redirect-heading'] = '[[Wikipedia:Redirect|{{PLURAL:$1|Redirect|Redirects}}]]',
-- The error message to display when a shortcut is invalid (is not a string, or
-- is the blank string). It accepts the following parameter:
-- $1 - the number of the shortcut in the argument list. (required)
['invalid-shortcut-error'] = 'shortcut #$1 was invalid (shortcuts must be ' ..
'strings of at least one character in length)',
-- The error message to display when no shortcuts or other displayable content
-- were specified. (required)
['no-content-error'] = 'Error: no shortcuts were specified and the ' ..
mw.text.nowiki('|msg=') ..
' parameter was not set.',
-- A category to add when the no-content-error message is displayed. (optional)
['no-content-error-category'] = 'Shortcut templates with missing parameters',
}
f9d1d94844d5953753eb19e30a3ce389eda3d319
Template:Param
10
136
276
275
2023-10-01T08:52:54Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{SAFESUBST:<noinclude />#ifeq:{{SAFESUBST:<noinclude />Yesno|{{{nested|no}}}}}|yes||<{{{tag|code}}}>}}{{{{{{1<noinclude>|foo</noinclude>}}}{{SAFESUBST:<noinclude />#ifeq:{{{2}}}|{{{2|}}} ||}}{{{2|}}}}}}{{SAFESUBST:<noinclude />#ifeq:{{SAFESUBST:<noinclude />Yesno|{{{nested|no}}}}}|yes||</{{{tag|code}}}>}}<noinclude>
{{Documentation}}
<!--
PLEASE ADD CATEGORIES AND INTERWIKIS
TO THE /doc SUBPAGE, THANKS
-->
</noinclude>
abdb5d7fe0982064ea62ad15e8298d1693ed69e2
Template:Never substitute
10
137
278
277
2023-10-01T08:52:55Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{Always substitute|yesnomaybe=never}}<noinclude>
{{Documentation}}
</noinclude>
fda3e0330f5da78bbcd49a4f97ec81a6a3c78cd5
Template:Template shortcut
10
138
280
279
2023-10-01T08:52:55Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<includeonly>{{#invoke:Shortcut|main|template=yes}}</includeonly><noinclude>{{Documentation}}</noinclude>
bfb2889c4c0ec36294b7b667f5e03350d2df680e
Module:Transclusion count/data/D
828
139
282
281
2023-10-01T08:52:56Z
Reverie
2
1 revision imported
Scribunto
text/plain
return {
["D&D"] = 3900,
["D&D_to-do"] = 5600,
["D-da"] = 2600,
["DANFS"] = 8400,
["DC-Comics-trademark-copyright"] = 2100,
["DCS_Sri_Lanka"] = 2100,
["DDR"] = 2800,
["DEC"] = 8700,
["DECADE"] = 283000,
["DEN"] = 6800,
["DEU"] = 17000,
["DMC"] = 58000,
["DMCA"] = 2350000,
["DNB"] = 8800,
["DNB-Portal"] = 2100,
["DNB_portal"] = 3800,
["DNK"] = 7800,
["DNZB"] = 3600,
["DOM"] = 2100,
["DOWs"] = 2700,
["DRV_links"] = 3600,
["DWT"] = 2300,
["DYKC"] = 6700,
["DYKF"] = 2100,
["DYK_blue"] = 3400,
["DYK_checklist"] = 14000,
["DYK_conditions"] = 67000,
["DYK_files"] = 2100,
["DYK_header"] = 34000,
["DYK_nompage_links"] = 79000,
["DYK_talk"] = 103000,
["DYK_talk/date"] = 103000,
["DYK_tools"] = 52000,
["DYK_tools/styles.css"] = 52000,
["DYKfile"] = 12000,
["DZA"] = 2800,
["Dab"] = 18000,
["Dagger"] = 18000,
["Dashboard.wikiedu.org_assignment"] = 14000,
["Dashboard.wikiedu.org_bibliography/guide"] = 6700,
["Dashboard.wikiedu.org_course_header"] = 6200,
["Dashboard.wikiedu.org_course_header/edit-note"] = 6200,
["Dashboard.wikiedu.org_draft_template/about_this_sandbox"] = 10000,
["Dashboard.wikiedu.org_evaluate_article/guide"] = 8200,
["Dashboard.wikiedu.org_peer_review/guide"] = 12000,
["Dashboard.wikiedu.org_sandbox"] = 96000,
["Dashboard.wikiedu.org_student_editor"] = 84000,
["Dashboard.wikiedu.org_student_program_sandbox"] = 95000,
["Dashboard.wikiedu.org_talk_course_link"] = 85000,
["Dashboard.wikiedu.org_user_talk"] = 2200,
["Date"] = 42000,
["Date-mf"] = 39000,
["Date_table_sorting"] = 39000,
["Dated_maintenance_category"] = 2410000,
["Dated_maintenance_category_(articles)"] = 2350000,
["Dated_maintenance_category_by_type_(articles)"] = 22000,
["Davis_Cup_player"] = 2500,
["Day+1"] = 6900,
["Day-1"] = 8300,
["Dbox"] = 3000,
["Dda"] = 5200,
["Dead_YouTube_link"] = 2700,
["Dead_Youtube_links"] = 2200,
["Dead_link"] = 287000,
["Deadlink"] = 3100,
["Death-date"] = 11000,
["Death-date_and_age"] = 10000,
["Death_date"] = 9200,
["Death_date_and_age"] = 389000,
["Death_date_and_given_age"] = 2700,
["Death_date_text"] = 11000,
["Death_year_and_age"] = 16000,
["Death_year_category_header"] = 2000,
["Decade"] = 2100,
["Decade_link"] = 32000,
["Decimals"] = 3100,
["Decline"] = 2500,
["Declined"] = 3200,
["Decrease"] = 35000,
["Define"] = 4400,
["Deg2DMS"] = 3400,
["Deletion_review_log_header"] = 5700,
["Deletion_review_log_header/Core"] = 5700,
["Delink"] = 1990000,
["Delink_question_hyphen-minus"] = 295000,
["Delrevxfd"] = 3600,
["Democratic_Party_(US)/meta/shading"] = 15000,
["Description_missing"] = 7100,
["Designation/abbreviation"] = 8300,
["Designation/color"] = 76000,
["Designation/colour"] = 79000,
["Designation/colour2"] = 18000,
["Designation/divbox"] = 30000,
["Designation/text"] = 42000,
["Designation_list"] = 5400,
["Details"] = 4500,
["DetailsLink"] = 5900,
["Detect_singular"] = 202000,
["Deutsche_Bahn_station_codes"] = 2200,
["DfE_performance_tables"] = 4500,
["Diff"] = 30000,
["Diff2"] = 12000,
["Digits"] = 21000,
["Directories_box"] = 3200,
["Disamb"] = 2200,
["Disambig"] = 63000,
["Disambig-Class"] = 12000,
["DisambigProj"] = 12000,
["DisambigProject"] = 150000,
["Disambigproject"] = 5800,
["Disambiguation"] = 218000,
["Disambiguation/cat"] = 218000,
["Disambiguation_page_short_description"] = 354000,
["Discogs_artist"] = 17000,
["Discogs_master"] = 12000,
["Discogs_release"] = 3100,
["Discussion_bottom"] = 12000,
["Discussion_top"] = 13000,
["DisestcatCountry"] = 9500,
["DisestcatCountry/core"] = 9500,
["DisestcatCountryDecade"] = 2600,
["DisestcatUSstate"] = 4900,
["DisestcatUSstate/core"] = 4900,
["Disputed"] = 2200,
["Distinguish"] = 98000,
["Disused_Rail_Start"] = 3900,
["Disused_rail_start"] = 4300,
["Disused_style"] = 4700,
["Div_col"] = 400000,
["Div_col/styles.css"] = 401000,
["Div_col_end"] = 302000,
["Div_col_start"] = 2900,
["Div_end"] = 2700,
["Divbox"] = 347000,
["Divbox/styles.css"] = 370000,
["Dividing_line"] = 4000,
["Dmbox"] = 461000,
["Dmbox/styles.css"] = 461000,
["Do_not_move_to_Commons"] = 16000,
["Doc"] = 3600,
["Documentation"] = 121000,
["Documentation_subpage"] = 95000,
["Dog_opentask"] = 3500,
["Doi"] = 26000,
["Doing"] = 3600,
["Don't_edit_this_line"] = 108000,
["Don't_edit_this_line_always_display"] = 479000,
["Don't_edit_this_line_extinct"] = 479000,
["Don't_edit_this_line_link_target"] = 479000,
["Don't_edit_this_line_link_text"] = 479000,
["Don't_edit_this_line_parent"] = 479000,
["Don't_edit_this_line_rank"] = 479000,
["Don't_edit_this_line_refs"] = 108000,
["Don't_edit_this_line_same_as"] = 479000,
["Done"] = 103000,
["Doppelganger"] = 2800,
["Double+single"] = 2800,
["Double-dagger"] = 19000,
["Dr"] = 3400,
["Dr-logno"] = 3400,
["Dr-make"] = 3500,
["Dr-yr"] = 3400,
["Draft"] = 4300,
["Draft_article"] = 6400,
["Draft_article_check"] = 6500,
["Draft_categories"] = 8100,
["Draft_other"] = 112000,
["Draft_topics"] = 24000,
["Drafts_moved_from_mainspace"] = 8700,
["Draw"] = 3900,
["Draw_key"] = 18000,
["Draw_links"] = 13000,
["Drep"] = 3500,
["Drugbankcite"] = 4300,
["Drugbox"] = 7600,
["Drugs.com"] = 3800,
["Ds/talk_notice"] = 6400,
["Dts"] = 38000,
["Dubious"] = 8100,
["Duck"] = 2900,
["Dummytab"] = 5000,
["Duration"] = 38000,
["Dutch_municipality"] = 2700,
["Dyktalk"] = 42000,
["Dynamic_list"] = 10000,
["Module:DYK_checklist"] = 14000,
["Module:DYK_checklist/data"] = 14000,
["Module:DYK_nompage_links"] = 79000,
["Module:Data"] = 149000,
["Module:Date"] = 1380000,
["Module:DateI18n"] = 66000,
["Module:Date_table_sorting"] = 39000,
["Module:DecodeEncode"] = 117000,
["Module:Delink"] = 2080000,
["Module:Detect_singular"] = 1530000,
["Module:Disambiguation"] = 15800000,
["Module:Disambiguation/templates"] = 15400000,
["Module:Distinguish"] = 98000,
["Module:Documentation"] = 167000,
["Module:Documentation/config"] = 167000,
["Module:Documentation/styles.css"] = 167000,
["Module:Draft_topics"] = 24000,
["Module:Duration"] = 238000,
}
8f683619a2978bf72bfba8daad66e905645f9921
Template:Documentation/doc
10
140
284
283
2023-10-01T08:52:58Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<noinclude>{{pp-semi-indef}}
</noinclude>{{Distinguish|Template:Documentation subpage}}
{{Documentation subpage}}
{{template shortcut|doc}}
{{High-use}}
{{Lua|Module:Documentation}}
{{Never substitute}}
The {{tlx|documentation}} template is used to contain the [[WP:TDOC|documented information and instructions]] of a certain template, usually from a /doc subpage. It can also be configured to load the content from other pages or be directly fed by text.
For detailed instructions on how and when to use this template, see [[Wikipedia:Template documentation]] (shortcut: [[WP:TDOC]]).
This template has two parts: the big "documentation box" with the documentation inside alongside a toolbar (the <code>[view][edit][hist][purge]</code> links), and the smaller "link box" that shows metadata about the documentation alongside the [[Wikipedia:Template sandbox and test cases|sandbox and testcases]] links.
Use of this template allows templates to be [[Wikipedia:Protection policy|protected]], where necessary, while allowing anyone to edit the documentation and categories.
== General syntax ==
Normally, the template is used without parameters and is placed inside {{tag|noinclude}} at the bottom of the template page (see {{section link|#Placement and tags}} for more information):
<syntaxhighlight lang="wikitext">
<!--Last line of your template code--><noinclude>
{{Documentation}}
<!-- Add categories to the /doc subpage -->
</noinclude>
</syntaxhighlight>
=== Transcluding a different page ===
To transclude a different page other than the /doc subpage, simply provide {{para|1}} like this:
<syntaxhighlight lang="wikitext">
<!--Last line of your template code--><noinclude>
{{Documentation|Template:Other page/doc}}
</noinclude>
</syntaxhighlight>
Note that when loading the documentation from a page other than the local /doc subpage, it becomes tricky to handle the categories.
=== Using the {{para|content}} parameter ===
The documentation can also be fed directly as text, by using the {{para|content}} parameter:
<syntaxhighlight lang="wikitext">
<!--Last line of your template code--><noinclude>
{{Documentation
| content =
<!-- template documentation -->
}}</noinclude>
</syntaxhighlight>
When using this parameter, the toolbar will not show. Note that the /doc subpage in the link box will still show up if it exists.
Also note that when {{para|1}} and {{para|content}} is specified, {{para|content}} takes precedence and always shows in the documentation box.
== Advanced syntax ==
=== Customizing the heading ===
The heading in the documentation box changes depending on namespace. See the below list for the default text in each namespace:
* Template namespace: [[File:Test Template Info-Icon - Version (2).svg|32px|link=[[Wikipedia:Template documentation]]]] '''Template documentation'''
* Module namespace: [[File:Test Template Info-Icon - Version (2).svg|32px|link=[[Wikipedia:Template documentation]]]] '''Module documentation'''
* Other namespaces: '''Documentation'''
To customize the heading, simply set the parameter {{para|heading}} to anything you like, for example {{para|heading|Infobox documentation}}.
Note that if the heading parameter is empty but defined (like {{para|heading|}}) the heading alongside the toolbar will not show.
The {{para|heading-style}} parameter can be fed optional [[Cascading Style Sheets|CSS]] values, like {{para|heading-style|font-size:150%;color:red;}}. Not that you should omit quotation marks <code>" "</code> and add the ending semicolon <code>;</code>.
=== Customizing the link box ===
To customize the link box, simply set {{para|link box}} to something else, like {{para|link box|The above documentation is automatically generated from [[Template:Foo]]}}.
To hide the link box, simply set {{para|link box}} to <code>off</code>.
=== Testing ===
You can simulate the output for a given page by using the {{para|page}} parameter. For example, if you use the code {{para|page|Template:Edit protected}}, the template will behave exactly as if it were on the page [[Template:Edit protected]], including showing the documentation from [[Template:Edit protected/doc]], linking to [[Template:Edit protected/sandbox]], etc. This parameter is useful for testing and is used extensively on the [[Module:Documentation/testcases|module testcases page]].
== Placement and tags ==
{{Further information|Wikipedia:Template documentation#Where to place it}}
This code should be added at the bottom of the template code page, with no space before {{Tag|noinclude|o}} (which causes extra whitespace to show on pages where the template is transcluded):
<syntaxhighlight lang="wikitext"><!--Last line of your template code--><noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage -->
</noinclude></syntaxhighlight>
To automatically insert the above text, you can also use the [[Wikipedia:Substitution|substitution]] code shortcut {{tlxs|doc-code}}.
=== Categories and interwikis ===
Depending on where to the documentation is placed, it may be tricky to handle the categories and interwikis. See {{section link|Wikipedia:Template documentation#Categories and interwiki links}} for information about adding these.
== Technical details ==
=== Automatic functions ===
If the documentation page does not exist, the toolbar is replaced with a <code>[create]</code> link. It automatically [[mw:Manual:Creating pages with preloaded text|creates the page with preloaded text]] with the basic documentation syntax. Preload text is also used for the /sandbox and /testcases [create] links.
The preload page for the /doc <code>[create]</code> link is [[Template:Documentation/preload]]. The preload pages for the /sandbox and /testcases links are [[Template:Documentation/preload-sandbox]] and [[Template:Documentation/preload-testcases]]. The preload page for the /sandbox <code>[mirror]</code> link is [[Template:Documentation/mirror]].
This template also automatically adds {{tl|pp-template}} to a protected template page, so no need to manually add this template to protected pages.
When this template is on a /sandbox subpage it automatically adds the {{tl|Template sandbox notice}} template.
=== Link box features ===
Depending on the namespace, the link box may have less features, or may not show up at all. The following table shows this:
{| class="wikitable"
! Namespace
! Behavior
|-
| Template
| Full behavior
|-
| Module
| Full behavior, with the addition of a "create documentation" link when the page does not exist
|-
| User
| Full behavior
|-
| Other namespaces
| Hidden, unless {{para|1}} is specified (which will show "The above documentation is transcluded from {{param|1}}")
|}
Alongside that, if {{para|1}} or {{para|content}} is specified, the "Add categories to the /doc subpage" will not show.
=== Subject namespaces vs. talk namespaces ===
This template is usually placed in the [[WP:NS#Subject namespaces|subject namespace]]. But in some cases this template needs to be on the [[WP:TALKSPACE|Talk namespace]]:
* In the MediaWiki namespace, since {{tag|noinclude|o}} often does not work in system messages, and since the MediaWiki namespace needs to be kept clean for performance reasons.
When placed on talk pages, this template usually is placed near the top of the page and without {{tag|noinclude}} tags.
The /doc, /sandbox and /testcases pages should normally be in the subject namespace, except in the namespaces that do not have the MediaWiki [[meta:Help:Link#Subpage feature|subpage feature]] enabled: Main, File, and MediaWiki. (Categories can have subpages, but documentation is created in the Category talk namespace to prevent creating empty categories. There are also a whole bunch of other technical reasons why the /doc page must be stored under the talk page for those (but only those) namespaces.
This template automatically points its [create] links for the /doc, /sandbox and /testcases to the right namespace.
== Full syntax ==
<syntaxhighlight lang="wikitext">
{{Documentation}}
or
{{Documentation
| [path to documentation page]
}}
{{Documentation
| content =
}}
or
{{Documentation
| [path to documentation page]
| heading-style =
| heading =
| link box =
}}
or
{{Documentation
| [path to documentation page]
| content =
| heading-style =
| heading =
| link box =
| page =
}}
</syntaxhighlight>
=== Color scheme ===
{| class="wikitable" style="font-size:90%"
|+ Wikipedia background colors for {{Template link|documentation}} <small>([[Help:Using colors]])</small>
! !! RGB !! HSV !! Color !! General usage !! Note
|-
| A
| <kbd>#ECFCF4</kbd> || 150°, 6%, 99%
| style="background:#ECFCF4" |
| Sample || Current documentation background
|-
| B
| <kbd>#00FF80</kbd>
| style="font-size:90%;" | {{nowrap|1=Hue=150° <small>(41.7%; 106/255<small>dec</small>)</small> 100%, 100%}}
| style="background:#00FF80" |
| Basic hue || What we'd call ''the color''
|-
| colspan="6" |
|-
| 1
| <kbd>#A3BFB1</kbd> || 150°, 15%, 75%
| style="background:#A3BFB1" |
| Header border only ||
|-
| 2
| <kbd>#CEF2E0</kbd> || 150°, 15%, 95%
| style="background:#CEF2E0" |
| Main border; header background ||
|-
| 3
| <kbd>#E6FFF2</kbd> || 150°, 10%, 100%
| style="background:#E6FFF2" |
| 2nd header, accent colour ||
|-
| 4
| <kbd>#F5FFFA</kbd> || 150°, 4%, 100%
| style="background:#F5FFFA" |
| Main background || So saturation in A is a bit off
|}
{{collapse top|title=Colors for documentation navbox}}
As a suggestion, here are colors for a navbox intended for documentation pages only.
They follow the shading of regular blue navbox colors:
<syntaxhighlight lang="wikitext">
| titlestyle = background:#ccffe5
| basestyle = background:#ddffee
<!-- basestyle= sets groupstyle, abovestyle, belowstyle together -->
</syntaxhighlight>
For subgroups, in child navboxes:
<syntaxhighlight lang="wikitext">
{{Navbox|child
| groupstyle = background:#e6fff2
...
</syntaxhighlight>
Example:{{Template link expanded|Periodic table templates}}
{{collapse bottom}}
==See also==
* {{tl|Documentation subpage}}, a notice placed at the top of a /doc subpage explaining its role and including a link to the page it documents.
* {{tl|Barnstar documentation}}, a variant of {{tl|Documentation}} for use with [[Wikipedia:Barnstars|barnstar]] templates.
* [[Wikipedia:Template documentation]] is a how-to guide to template documentation.
* [[Wikipedia:Template sandbox and test cases]] explains the use of /sandbox and /testcases subpages and includes more information about template testing.
<includeonly><!-- Make sure that only page [[Template:Documentation]] is categorised. No other page (no subpages, not when transcluded).
-->{{#ifeq:{{FULLPAGENAME}}|Template:Documentation|
[[Category:Template documentation| ]]
[[Category:Template namespace templates|Documentation]]
}}</includeonly>
431959208b67db006bc22ce92572aa643072c326
Module:Shortcut/styles.css
828
141
286
285
2023-10-01T08:52:59Z
Reverie
2
1 revision imported
text
text/plain
/* {{pp-template}} */
.module-shortcutboxplain {
float: right;
margin: 0 0 0 1em;
border: 1px solid #aaa;
background: #fff;
padding: 0.3em 0.6em 0.2em 0.6em;
text-align: center;
font-size: 85%;
}
.module-shortcutboxleft {
float: left;
margin: 0 1em 0 0;
}
.module-shortcutlist {
display: inline-block;
border-bottom: 1px solid #aaa;
margin-bottom: 0.2em;
}
.module-shortcutboxplain ul {
font-weight: bold;
}
.module-shortcutanchordiv {
position: relative;
top: -3em;
}
li .module-shortcutanchordiv {
float: right; /* IE/Edge in list items */
}
.mbox-imageright .module-shortcutboxplain {
padding: 0.4em 1em 0.4em 1em;
line-height: 1.3;
margin: 0;
}
ccf3877e4b14726147d3b1d8a297fbecacdb2cf8
Template:Reply to
10
142
288
287
2023-10-01T08:53:00Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{<includeonly>safesubst:</includeonly>#invoke:Reply to|replyto|<noinclude>example=Example</noinclude>|max=50}}<noinclude>
{{documentation}}
</noinclude>
3ce97caf39fd21ca2f3a2f4a0be73b1ddd31074e
Template:Ping
10
143
290
289
2023-10-01T08:53:00Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Reply to]]
{{Redirect category shell|
{{R from template shortcut}}
}}
6284a6c588bec5d4885fa23cd56f6535b7fc596f
Module:Reply to
828
144
292
291
2023-10-01T08:53:00Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p = {}
local function makeError(msg)
msg ='Error in [[Template:Reply to]]: ' .. msg
return mw.text.tag('strong', {['class']='error'}, msg)
end
function p.replyto(frame)
local origArgs = frame:getParent().args
local args = {}
local maxArg = 1
local usernames = 0
for k, v in pairs(origArgs) do
if type(k) == 'number' then
if mw.ustring.match(v,'%S') then
if k > maxArg then maxArg = k end
usernames = usernames + 1
local title = mw.title.new(v)
if not title then return makeError('Input contains forbidden characters.') end
args[k] = title.rootText
end
elseif v == '' and k:sub(0,5) == 'label' then
args[k] = '​'
else
args[k] = v
end
end
if usernames > (tonumber(frame.args.max) or 50) then
return makeError(string.format(
'More than %s names specified.',
tostring(frame.args.max or 50)
))
else
if usernames < 1 then
if frame.args.example then args[1] = frame.args.example else return makeError('Username not given.') end
end
args['label1'] = args['label1'] or args['label']
local isfirst = true
local outStr = args['prefix'] or '@'
for i = 1, maxArg do
if args[i] then
if isfirst then
isfirst = false
else
if ( (usernames > 2) or ((usernames == 2) and (args['c'] == '')) ) then outStr = outStr..', ' end
if i == maxArg then outStr = outStr..' '..(args['c'] or 'and') .. ' ' end
end
outStr = string.format(
'%s[[User:%s|%s]]',
outStr,
args[i],
args['label'..tostring(i)] or args[i]
)
end
end
outStr = outStr..(args['p'] or ':')
return mw.text.tag('span', {['class']='template-ping'}, outStr)
end
end
return p
14f0cd73a8a9f122c0e0e15382219083c602c62a
Template:Replace
10
145
294
293
2023-10-01T08:53:01Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{<includeonly>safesubst:</includeonly>#invoke:String|replace|source={{{1}}}|{{{2}}}|{{{3}}}|plain={{{plain|true}}}|count={{{count|}}}}}<noinclude>
{{documentation}}
</noinclude>
4192ba916713e0f44fdfd0f8e0d9d105c0c85472
Module:Math
828
146
296
295
2023-10-01T08:53:01Z
Reverie
2
1 revision imported
Scribunto
text/plain
--[[
This module provides a number of basic mathematical operations.
]]
local yesno, getArgs -- lazily initialized
local p = {} -- Holds functions to be returned from #invoke, and functions to make available to other Lua modules.
local wrap = {} -- Holds wrapper functions that process arguments from #invoke. These act as intemediary between functions meant for #invoke and functions meant for Lua.
--[[
Helper functions used to avoid redundant code.
]]
local function err(msg)
-- Generates wikitext error messages.
return mw.ustring.format('<strong class="error">Formatting error: %s</strong>', msg)
end
local function unpackNumberArgs(args)
-- Returns an unpacked list of arguments specified with numerical keys.
local ret = {}
for k, v in pairs(args) do
if type(k) == 'number' then
table.insert(ret, v)
end
end
return unpack(ret)
end
local function makeArgArray(...)
-- Makes an array of arguments from a list of arguments that might include nils.
local args = {...} -- Table of arguments. It might contain nils or non-number values, so we can't use ipairs.
local nums = {} -- Stores the numbers of valid numerical arguments.
local ret = {}
for k, v in pairs(args) do
v = p._cleanNumber(v)
if v then
nums[#nums + 1] = k
args[k] = v
end
end
table.sort(nums)
for i, num in ipairs(nums) do
ret[#ret + 1] = args[num]
end
return ret
end
local function fold(func, ...)
-- Use a function on all supplied arguments, and return the result. The function must accept two numbers as parameters,
-- and must return a number as an output. This number is then supplied as input to the next function call.
local vals = makeArgArray(...)
local count = #vals -- The number of valid arguments
if count == 0 then return
-- Exit if we have no valid args, otherwise removing the first arg would cause an error.
nil, 0
end
local ret = table.remove(vals, 1)
for _, val in ipairs(vals) do
ret = func(ret, val)
end
return ret, count
end
--[[
Fold arguments by selectively choosing values (func should return when to choose the current "dominant" value).
]]
local function binary_fold(func, ...)
local value = fold((function(a, b) if func(a, b) then return a else return b end end), ...)
return value
end
--[[
random
Generate a random number
Usage:
{{#invoke: Math | random }}
{{#invoke: Math | random | maximum value }}
{{#invoke: Math | random | minimum value | maximum value }}
]]
function wrap.random(args)
local first = p._cleanNumber(args[1])
local second = p._cleanNumber(args[2])
return p._random(first, second)
end
function p._random(first, second)
math.randomseed(mw.site.stats.edits + mw.site.stats.pages + os.time() + math.floor(os.clock() * 1000000000))
-- math.random will throw an error if given an explicit nil parameter, so we need to use if statements to check the params.
if first and second then
if first <= second then -- math.random doesn't allow the first number to be greater than the second.
return math.random(first, second)
end
elseif first then
return math.random(first)
else
return math.random()
end
end
--[[
order
Determine order of magnitude of a number
Usage:
{{#invoke: Math | order | value }}
]]
function wrap.order(args)
local input_string = (args[1] or args.x or '0');
local input_number = p._cleanNumber(input_string);
if input_number == nil then
return err('order of magnitude input appears non-numeric')
else
return p._order(input_number)
end
end
function p._order(x)
if x == 0 then return 0 end
return math.floor(math.log10(math.abs(x)))
end
--[[
precision
Detemines the precision of a number using the string representation
Usage:
{{ #invoke: Math | precision | value }}
]]
function wrap.precision(args)
local input_string = (args[1] or args.x or '0');
local trap_fraction = args.check_fraction;
local input_number;
if not yesno then
yesno = require('Module:Yesno')
end
if yesno(trap_fraction, true) then -- Returns true for all input except nil, false, "no", "n", "0" and a few others. See [[Module:Yesno]].
local pos = string.find(input_string, '/', 1, true);
if pos ~= nil then
if string.find(input_string, '/', pos + 1, true) == nil then
local denominator = string.sub(input_string, pos+1, -1);
local denom_value = tonumber(denominator);
if denom_value ~= nil then
return math.log10(denom_value);
end
end
end
end
input_number, input_string = p._cleanNumber(input_string);
if input_string == nil then
return err('precision input appears non-numeric')
else
return p._precision(input_string)
end
end
function p._precision(x)
if type(x) == 'number' then
x = tostring(x)
end
x = string.upper(x)
local decimal = x:find('%.')
local exponent_pos = x:find('E')
local result = 0;
if exponent_pos ~= nil then
local exponent = string.sub(x, exponent_pos + 1)
x = string.sub(x, 1, exponent_pos - 1)
result = result - tonumber(exponent)
end
if decimal ~= nil then
result = result + string.len(x) - decimal
return result
end
local pos = string.len(x);
while x:byte(pos) == string.byte('0') do
pos = pos - 1
result = result - 1
if pos <= 0 then
return 0
end
end
return result
end
--[[
max
Finds the maximum argument
Usage:
{{#invoke:Math| max | value1 | value2 | ... }}
Note, any values that do not evaluate to numbers are ignored.
]]
function wrap.max(args)
return p._max(unpackNumberArgs(args))
end
function p._max(...)
local max_value = binary_fold((function(a, b) return a > b end), ...)
if max_value then
return max_value
end
end
--[[
median
Find the median of set of numbers
Usage:
{{#invoke:Math | median | number1 | number2 | ...}}
OR
{{#invoke:Math | median }}
]]
function wrap.median(args)
return p._median(unpackNumberArgs(args))
end
function p._median(...)
local vals = makeArgArray(...)
local count = #vals
table.sort(vals)
if count == 0 then
return 0
end
if p._mod(count, 2) == 0 then
return (vals[count/2] + vals[count/2+1])/2
else
return vals[math.ceil(count/2)]
end
end
--[[
min
Finds the minimum argument
Usage:
{{#invoke:Math| min | value1 | value2 | ... }}
OR
{{#invoke:Math| min }}
When used with no arguments, it takes its input from the parent
frame. Note, any values that do not evaluate to numbers are ignored.
]]
function wrap.min(args)
return p._min(unpackNumberArgs(args))
end
function p._min(...)
local min_value = binary_fold((function(a, b) return a < b end), ...)
if min_value then
return min_value
end
end
--[[
sum
Finds the sum
Usage:
{{#invoke:Math| sum | value1 | value2 | ... }}
OR
{{#invoke:Math| sum }}
Note, any values that do not evaluate to numbers are ignored.
]]
function wrap.sum(args)
return p._sum(unpackNumberArgs(args))
end
function p._sum(...)
local sums, count = fold((function(a, b) return a + b end), ...)
if not sums then
return 0
else
return sums
end
end
--[[
average
Finds the average
Usage:
{{#invoke:Math| average | value1 | value2 | ... }}
OR
{{#invoke:Math| average }}
Note, any values that do not evaluate to numbers are ignored.
]]
function wrap.average(args)
return p._average(unpackNumberArgs(args))
end
function p._average(...)
local sum, count = fold((function(a, b) return a + b end), ...)
if not sum then
return 0
else
return sum / count
end
end
--[[
round
Rounds a number to specified precision
Usage:
{{#invoke:Math | round | value | precision }}
--]]
function wrap.round(args)
local value = p._cleanNumber(args[1] or args.value or 0)
local precision = p._cleanNumber(args[2] or args.precision or 0)
if value == nil or precision == nil then
return err('round input appears non-numeric')
else
return p._round(value, precision)
end
end
function p._round(value, precision)
local rescale = math.pow(10, precision or 0);
return math.floor(value * rescale + 0.5) / rescale;
end
--[[
log10
returns the log (base 10) of a number
Usage:
{{#invoke:Math | log10 | x }}
]]
function wrap.log10(args)
return math.log10(args[1])
end
--[[
mod
Implements the modulo operator
Usage:
{{#invoke:Math | mod | x | y }}
--]]
function wrap.mod(args)
local x = p._cleanNumber(args[1])
local y = p._cleanNumber(args[2])
if not x then
return err('first argument to mod appears non-numeric')
elseif not y then
return err('second argument to mod appears non-numeric')
else
return p._mod(x, y)
end
end
function p._mod(x, y)
local ret = x % y
if not (0 <= ret and ret < y) then
ret = 0
end
return ret
end
--[[
gcd
Calculates the greatest common divisor of multiple numbers
Usage:
{{#invoke:Math | gcd | value 1 | value 2 | value 3 | ... }}
--]]
function wrap.gcd(args)
return p._gcd(unpackNumberArgs(args))
end
function p._gcd(...)
local function findGcd(a, b)
local r = b
local oldr = a
while r ~= 0 do
local quotient = math.floor(oldr / r)
oldr, r = r, oldr - quotient * r
end
if oldr < 0 then
oldr = oldr * -1
end
return oldr
end
local result, count = fold(findGcd, ...)
return result
end
--[[
precision_format
Rounds a number to the specified precision and formats according to rules
originally used for {{template:Rnd}}. Output is a string.
Usage:
{{#invoke: Math | precision_format | number | precision }}
]]
function wrap.precision_format(args)
local value_string = args[1] or 0
local precision = args[2] or 0
return p._precision_format(value_string, precision)
end
function p._precision_format(value_string, precision)
-- For access to Mediawiki built-in formatter.
local lang = mw.getContentLanguage();
local value
value, value_string = p._cleanNumber(value_string)
precision = p._cleanNumber(precision)
-- Check for non-numeric input
if value == nil or precision == nil then
return err('invalid input when rounding')
end
local current_precision = p._precision(value)
local order = p._order(value)
-- Due to round-off effects it is neccesary to limit the returned precision under
-- some circumstances because the terminal digits will be inaccurately reported.
if order + precision >= 14 then
if order + p._precision(value_string) >= 14 then
precision = 13 - order;
end
end
-- If rounding off, truncate extra digits
if precision < current_precision then
value = p._round(value, precision)
current_precision = p._precision(value)
end
local formatted_num = lang:formatNum(math.abs(value))
local sign
-- Use proper unary minus sign rather than ASCII default
if value < 0 then
sign = '−'
else
sign = ''
end
-- Handle cases requiring scientific notation
if string.find(formatted_num, 'E', 1, true) ~= nil or math.abs(order) >= 9 then
value = value * math.pow(10, -order)
current_precision = current_precision + order
precision = precision + order
formatted_num = lang:formatNum(math.abs(value))
else
order = 0;
end
formatted_num = sign .. formatted_num
-- Pad with zeros, if needed
if current_precision < precision then
local padding
if current_precision <= 0 then
if precision > 0 then
local zero_sep = lang:formatNum(1.1)
formatted_num = formatted_num .. zero_sep:sub(2,2)
padding = precision
if padding > 20 then
padding = 20
end
formatted_num = formatted_num .. string.rep('0', padding)
end
else
padding = precision - current_precision
if padding > 20 then
padding = 20
end
formatted_num = formatted_num .. string.rep('0', padding)
end
end
-- Add exponential notation, if necessary.
if order ~= 0 then
-- Use proper unary minus sign rather than ASCII default
if order < 0 then
order = '−' .. lang:formatNum(math.abs(order))
else
order = lang:formatNum(order)
end
formatted_num = formatted_num .. '<span style="margin:0 .15em 0 .25em">×</span>10<sup>' .. order .. '</sup>'
end
return formatted_num
end
--[[
divide
Implements the division operator
Usage:
{{#invoke:Math | divide | x | y | round= | precision= }}
--]]
function wrap.divide(args)
local x = args[1]
local y = args[2]
local round = args.round
local precision = args.precision
if not yesno then
yesno = require('Module:Yesno')
end
return p._divide(x, y, yesno(round), precision)
end
function p._divide(x, y, round, precision)
if y == nil or y == "" then
return err("Empty divisor")
elseif not tonumber(y) then
if type(y) == 'string' and string.sub(y, 1, 1) == '<' then
return y
else
return err("Not a number: " .. y)
end
elseif x == nil or x == "" then
return err("Empty dividend")
elseif not tonumber(x) then
if type(x) == 'string' and string.sub(x, 1, 1) == '<' then
return x
else
return err("Not a number: " .. x)
end
else
local z = x / y
if round then
return p._round(z, 0)
elseif precision then
return p._round(z, precision)
else
return z
end
end
end
--[[
Helper function that interprets the input numerically. If the
input does not appear to be a number, attempts evaluating it as
a parser functions expression.
]]
function p._cleanNumber(number_string)
if type(number_string) == 'number' then
-- We were passed a number, so we don't need to do any processing.
return number_string, tostring(number_string)
elseif type(number_string) ~= 'string' or not number_string:find('%S') then
-- We were passed a non-string or a blank string, so exit.
return nil, nil;
end
-- Attempt basic conversion
local number = tonumber(number_string)
-- If failed, attempt to evaluate input as an expression
if number == nil then
local success, result = pcall(mw.ext.ParserFunctions.expr, number_string)
if success then
number = tonumber(result)
number_string = tostring(number)
else
number = nil
number_string = nil
end
else
number_string = number_string:match("^%s*(.-)%s*$") -- String is valid but may contain padding, clean it.
number_string = number_string:match("^%+(.*)$") or number_string -- Trim any leading + signs.
if number_string:find('^%-?0[xX]') then
-- Number is using 0xnnn notation to indicate base 16; use the number that Lua detected instead.
number_string = tostring(number)
end
end
return number, number_string
end
--[[
Wrapper function that does basic argument processing. This ensures that all functions from #invoke can use either the current
frame or the parent frame, and it also trims whitespace for all arguments and removes blank arguments.
]]
local mt = { __index = function(t, k)
return function(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
return wrap[k](getArgs(frame)) -- Argument processing is left to Module:Arguments. Whitespace is trimmed and blank arguments are removed.
end
end }
return setmetatable(p, mt)
2bbe734d898299f65412963a3c1782e9fcc4d9ca
Template:1x
10
147
298
297
2023-10-01T08:53:02Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{{1}}}<noinclude>
{{documentation}}
</noinclude>
da9241fe72a0821a30e22604f4284d06c326190e
Template:Doc
10
148
300
299
2023-10-01T08:53:02Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
#REDIRECT [[Template:Documentation]]
{{rcat shell|
{{R from template shortcut}}
}}
524178a0a060e3b8757c421009f8c9f4f6b7cc4d
Module:LuaCall
828
149
302
301
2023-10-01T08:53:03Z
Reverie
2
1 revision imported
Scribunto
text/plain
local p={}
function p.main(frame)
local parent = frame.getParent(frame) or {}
local reserved_value = {}
local reserved_function, reserved_contents
for k, v in pairs(parent.args or {}) do
_G[k] = tonumber(v) or v -- transfer every parameter directly to the global variable table
end
for k, v in pairs(frame.args or {}) do
_G[k] = tonumber(v) or v -- transfer every parameter directly to the global variable table
end
--- Alas Scribunto does NOT implement coroutines, according to
--- http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#string.format
--- this will not stop us from trying to implement one single lousy function call
if _G[1] then
reserved_function, reserved_contents = mw.ustring.match(_G[1], "^%s*(%a[^%s%(]*)%(([^%)]*)%)%s*$")
end
if reserved_contents then
local reserved_counter = 0
repeat
reserved_counter = reserved_counter + 1
reserved_value[reserved_counter] = _G[mw.ustring.match(reserved_contents, "([^%,]+)")]
reserved_contents = mw.ustring.match(reserved_contents, "[^%,]+,(.*)$")
until not reserved_contents
end
local reserved_arraypart = _G
while mw.ustring.match(reserved_function, "%.") do
reserved_functionpart, reserved_function = mw.ustring.match(reserved_function, "^(%a[^%.]*)%.(.*)$")
reserved_arraypart = reserved_arraypart[reserved_functionpart]
end
local reserved_call = reserved_arraypart[reserved_function]
if type(reserved_call) ~= "function" then
return tostring(reserved_call)
else
reserved_output = {reserved_call(unpack(reserved_value))}
return reserved_output[reserved_return or 1]
end
end
local function tonumberOrString(v)
return tonumber(v) or v:gsub("^\\", "", 1)
end
local function callWithTonumberOrStringOnPairs(f, ...)
local args = {}
for _, v in ... do
table.insert(args, tonumberOrString(v))
end
return (f(unpack(args)))
end
--[[
------------------------------------------------------------------------------------
-- ipairsAtOffset
-- This is an iterator for arrays. It can be used like ipairs, but with
-- specified i as first index to iterate. i is an offset from 1
--
------------------------------------------------------------------------------------
--]]
local function ipairsAtOffset(t, i)
local f, s, i0 = ipairs(t)
return f, s, i0+i
end
local function get(s)
local G = _G; for _ in mw.text.gsplit(
mw.text.trim(s, '%s'), '%s*%.%s*'
) do
G = G[_]
end
return G
end
--[[
------------------------------------------------------------------------------------
-- call
--
-- This function is usually useful for debugging template parameters.
-- Prefix parameter with backslash (\) to force interpreting parameter as string.
-- The leading backslash will be removed before passed to Lua function.
--
-- Example:
-- {{#invoke:LuaCall|call|mw.log|a|1|2|3}} will return results of mw.log('a', 1, 2, 3)
-- {{#invoke:LuaCall|call|mw.logObject|\a|321|\321| \321 }} will return results of mw.logObject('a', 321, '321', ' \\321 ')
--
-- This example show the debugging to see which Unicode characters are allowed in template parameters,
-- {{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0061}}}} return 97
-- {{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0000}}}} return 65533
-- {{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0001}}}} return 65533
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0002}}}}}} return 0xfffd
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x007e}}}}}} return 0x007e
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x007f}}}}}} return 0x007f
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x0080}}}}}} return 0x0080
-- {{#invoke:LuaCall|call|string.format|0x%04x|{{#invoke:LuaCall|call|mw.ustring.codepoint|{{#invoke:LuaCall|call|mw.ustring.char|0x00a0}}}}}} return 0x00a0
--
------------------------------------------------------------------------------------
--]]
function p.call(frame)
return callWithTonumberOrStringOnPairs(get(frame.args[1]),
ipairsAtOffset(frame.args, 1)
)
end
--local TableTools = require('Module:TableTools')
--[[
------------------------------------------------------------------------------------
-- get
--
-- Example:
-- {{#invoke:LuaCall|get| math.pi }} will return value of math.pi
-- {{#invoke:LuaCall|get|math|pi}} will return value of math.pi
-- {{#invoke:LuaCall|get| math |pi}} will return value of _G[' math '].pi
-- {{#invoke:LuaCall|get|_G| math.pi }} will return value of _G[' math.pi ']
-- {{#invoke:LuaCall|get|obj.a.5.c}} will return value of obj.a['5'].c
-- {{#invoke:LuaCall|get|obj|a|5|c}} will return value of obj.a[5].c
--
------------------------------------------------------------------------------------
--]]
function p.get(frame)
-- #frame.args always return 0, regardless of number of unnamed
-- template parameters, so check manually instead
if frame.args[2] == nil then
-- not do tonumber() for this args style,
-- always treat it as string,
-- so 'obj.1' will mean obj['1'] rather obj[1]
return get(frame.args[1])
else
local G = _G
for _, v in ipairs(frame.args) do
G = G[tonumberOrString(v)]
end
return G
end
end
--[[
------------------------------------------------------------------------------------
-- invoke
--
-- This function is used by Template:Invoke
--
------------------------------------------------------------------------------------
--]]
function p.invoke(frame)
local pframe, usedpargs = frame:getParent(), {}
-- get module and function names from parent args if not provided
local pfargs = setmetatable({frame.args[1], frame.args[2]}, {__index = table})
if not pfargs[1] then
pfargs[1], usedpargs[1] = pframe.args[1], true
if not pfargs[2] then
pfargs[2], usedpargs[2] = pframe.args[2], true
end
elseif not pfargs[2] then
pfargs[2], usedpargs[1] = pframe.args[1], true
end
-- repack sequential args
for i, v in ipairs(pframe.args) do
if not usedpargs[i] then
pfargs:insert(v)
usedpargs[i] = true
end
end
-- copy other args
for k, v in pairs(pframe.args) do
if not pfargs[k] and not usedpargs[k] then
pfargs[k], usedpargs[k] = v, true
end
end
-- #invoke off parent frame so the new frame has the same parent
return pframe:callParserFunction{name = '#invoke', args = pfargs}
end
return p
d6ec342627682bf90e61bbad921fcc6190f2e090
Template:Invoke/doc
10
150
304
303
2023-10-01T08:53:04Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{Documentation subpage}}
{{lua|Module:LuaCall}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
This template can be used to debug template parameters.
== Usage ==
* {<!---->{{{BASEPAGENAME}}|''module name''|''function name''|''arguments ...''}}
== Example ==
* {<!---->{{{BASEPAGENAME}}|math|random}} --> {{{{BASEPAGENAME}}|math|random}}
* {<!---->{{{BASEPAGENAME}}|math|min|9|7|8}} --> {{{{BASEPAGENAME}}|math|min|9|7|8}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject| arg1 |unnamed parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject| arg1 |unnamed parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4= arg1 |5=named parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4= arg1 |5=named parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject| ''<newline>''arg1''<newline>'' |unnamed parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|
arg1
|unnamed parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4= ''<newline>''arg1''<newline>'' |5=named parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4=
arg1
|5=named parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|''<newline>'' arg1 ''<newline>''|unnamed parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|
arg1
|unnamed parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4=''<newline>'' arg1 ''<newline>''|5=named parameter}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|4=
arg1
|5=named parameter}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|&lt;&gt;}} {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.logObject|&lt;&gt;}} {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|&lt;&gt;}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.dumpObject|<>}} {{{{BASEPAGENAME}}|LuaCall|call|mw.logObject|<>}} {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<pre>pre text</pre>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<pre>pre text</pre>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<nowiki>nowiki text</nowiki>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<nowiki>nowiki text</nowiki>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<ref>ref text</ref>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<ref>ref text</ref>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<code>code text</code>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<code>code text</code>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<syntaxhighlight lang=php>source text</syntaxhighlight>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<syntaxhighlight lang=php>source text</syntaxhighlight>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|{<!---->{ping|User1}}}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|{{ping|User1}}}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<nowiki>[[</nowiki>User:User1]]}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|[[User:User1]]}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<ref>ref then <nowiki>nowiki</nowiki></ref>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<ref>ref then <nowiki>nowiki</nowiki></ref>}}
* {<!---->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<pre>pre then <nowiki>nowiki</nowiki></pre>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<pre>pre then <nowiki>nowiki</nowiki></pre>}}
* {<!-- -->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|<nowiki>{{replace|<tag>tag text</tag>|tag|pre}}{{replace|<tag>tag text</tag>|tag|nowiki}}{{replace|<tag>tag text</tag>|tag|ref}}{{replace|<tag>tag text</tag>|tag|code}}{{replace|1=<tag lang=php>tag text</tag>|2=tag|3=syntaxhighlight}}</nowiki>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|{{replace|<tag>tag text</tag>|tag|pre}}{{replace|<tag>tag text</tag>|tag|nowiki}}{{replace|<tag>tag text</tag>|tag|ref}}{{replace|<tag>tag text</tag>|tag|code}}{{replace|1=<tag lang=php>tag text</tag>|2=tag|3=syntaxhighlight}}}}
* {<!-- -->{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|4={<!-- -->{1x|<}}pre>pre text</pre>{<!-- -->{1x|<}}nowiki>nowiki text</nowiki>{<!-- -->{1x|<}}ref>ref text</ref>{<!-- -->{1x|<}}code>code text</code>{<!-- -->{1x|<}}syntaxhighlight lang=php>source text</syntaxhighlight>}} --> {{{{BASEPAGENAME}}|LuaCall|call|mw.text.nowiki|4={{1x|<}}pre>pre text</pre>{{1x|<}}nowiki>nowiki text</nowiki>{{1x|<}}ref>ref text</ref>{{1x|<}}code>code text</code>{{1x|<}}syntaxhighlight lang=php>source text</syntaxhighlight>}}
<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
}}</includeonly>
6a343380b757a59de1283ae8a790e7cf4599ac8f
RMS Belle of England (1937)
0
151
313
2023-10-01T09:25:30Z
Reverie
2
Created page with "{{DISPLAYTITLE|string=RMS ''Belle of England'' (1937)}} Test"
wikitext
text/x-wiki
{{DISPLAYTITLE|string=RMS ''Belle of England'' (1937)}}
Test
0d28c2d1df549687d18e4ce5a0d1d6687b5f8966
314
313
2023-10-01T09:26:02Z
Reverie
2
wikitext
text/x-wiki
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
Test
df28c4a7dde8b4ee8183dc4a688592c0ebd54e40
315
314
2023-10-01T09:27:18Z
Reverie
2
wikitext
text/x-wiki
Test
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
d4d2c5d34ddede6c56ca8cbdf81d8aea0b397b34
316
315
2023-10-01T09:27:36Z
Reverie
2
Reverie moved page [[RMS Belle of England]] to [[RMS Belle of England (1937)]]
wikitext
text/x-wiki
Test
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
d4d2c5d34ddede6c56ca8cbdf81d8aea0b397b34
318
316
2023-10-01T09:29:51Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the line.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
cd1ddbd50a92506fda7c541ebba71dfcc32a792c
323
318
2023-10-01T10:47:10Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the line.
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
a8400b058b549e435358d4f4e3142f18af854dc0
334
323
2023-10-02T00:50:27Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the line.
{{Infobox ship career
|Hide header=
|Ship country=[[w:United Kingdom|United Kingdom]]
|Ship flag=
|Ship name=RMS ''Belle of England''
|Ship namesake=
|Ship owner=[[Transoceanic Maritime Company]]
|Ship operator=[[Belle Line]]
|Ship registry=[[w:Liverpool|Liverpool]], England
|Ship route=
|Ship ordered=
|Ship awarded=
|Ship builder=
|Ship original cost=
|Ship yard number=
|Ship way number=
|Ship laid down=
|Ship launched=
|Ship sponsor=
|Ship christened=
|Ship completed=
|Ship acquired=
|Ship commissioned=
|Ship recommissioned=
|Ship decommissioned=
|Ship maiden voyage=
|Ship in service=
|Ship out of service=
|Ship renamed=
|Ship reclassified=
|Ship refit=
|Ship stricken=
|Ship reinstated=
|Ship homeport=
|Ship identification=
|Ship motto=
|Ship nickname=The Pinkish Lady
|Ship honours=
|Ship honors=
|Ship captured=
|Ship fate=
|Ship status=
|Ship notes=
|Ship badge=
}}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
6f5182985f597fd665e92474f6ca1b84e6d59956
335
334
2023-10-02T00:52:18Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the line.
{{Infobox ship career
|Hide header=false
|Ship country=[[w:United Kingdom|United Kingdom]]
|Ship flag=
|Ship name=RMS ''Belle of England''
|Ship namesake=
|Ship owner=[[Transoceanic Maritime Company]]
|Ship operator=[[Belle Line]]
|Ship registry=[[w:Liverpool|Liverpool]], England
|Ship route=
|Ship ordered=
|Ship awarded=
|Ship builder=
|Ship original cost=
|Ship yard number=
|Ship way number=
|Ship laid down=
|Ship launched=
|Ship sponsor=
|Ship christened=
|Ship completed=
|Ship acquired=
|Ship commissioned=
|Ship recommissioned=
|Ship decommissioned=
|Ship maiden voyage=
|Ship in service=
|Ship out of service=
|Ship renamed=
|Ship reclassified=
|Ship refit=
|Ship stricken=
|Ship reinstated=
|Ship homeport=
|Ship identification=
|Ship motto=
|Ship nickname=The Pinkish Lady
|Ship honours=
|Ship honors=
|Ship captured=
|Ship fate=
|Ship status=
|Ship notes=
|Ship badge=
}}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
047f47f8576a567cf371b09dee6bf10627f857c0
336
335
2023-10-02T00:53:16Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
33254b296fc3c4715145cbd1de6592cbb1e1599e
337
336
2023-10-02T00:57:37Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! colspan="2" | {{{subj|RMS ''Belle of England''}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! Owner
| {{{[[Transoceanic Maritime Company]]}}}
|-
! Operator
| {{{operator|[[Belle Line]]}}
|-
! Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
13fa5d1777ae9ed9e7a21dee91cf1d06c33a15eb
338
337
2023-10-02T00:58:10Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! colspan="2" | {{{subj|RMS ''Belle of England''}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! Owner
| [[Transoceanic Maritime Company]]
|-
! Operator
| [[Belle Line]]
|-
! Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
2626b1f3009d74c8593ef063f512f6b225d63ab8
339
338
2023-10-02T01:05:24Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! colspan="2" style="background-colour:#CECEF2"| {{{subj|RMS ''Belle of England''}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! Owner
| [[Transoceanic Maritime Company]]
|-
! Operator
| [[Belle Line]]
|-
! Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
ed25b217592e60877c9f0c0e6a8d3eb86cc8efde
340
339
2023-10-02T01:06:16Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! style="background-colour:#CECEF2"| {{{subj|RMS ''Belle of England''}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! Owner
| [[Transoceanic Maritime Company]]
|-
! Operator
| [[Belle Line]]
|-
! Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
74244d884fa903b9ac2ac9d2d9bf6b56168467a7
341
340
2023-10-02T01:07:26Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable" rules="cols"
! style="background-colour:#CECEF2" colspan="2"| {{{subj|RMS ''Belle of England''}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! Owner
| [[Transoceanic Maritime Company]]
|-
! Operator
| [[Belle Line]]
|-
! Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
da29c4ff626b548b59b7bd029db7702073564862
342
341
2023-10-02T01:10:23Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! colspan="2"| {{{subj|RMS ''Belle of England''}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! Owner
| [[Transoceanic Maritime Company]]
|-
! Operator
| [[Belle Line]]
|-
! Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
b61db0c7e07ba6ccd8380fb0a622a7d4073355f6
343
342
2023-10-02T01:12:44Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! style="background: #CECEF2;" colspan="2"| {{{subj|RMS ''Belle of England''}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! Owner
| [[Transoceanic Maritime Company]]
|-
! Operator
| [[Belle Line]]
|-
! Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
458758fe7e11c8cc72ae6c74a892f6fca8c037b0
344
343
2023-10-02T01:27:24Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Transoceanic Maritime Company]]
|-
! style="background: #f8f9fb;"| Operator
| [[Belle Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
8b06ca1816f88fb0f52966dbf00e39f0092fe38d
346
344
2023-10-02T01:37:08Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! colspan="2" | [[File:{{{img|Belle of England in Jersey (1939).jpeg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Belle of England'' at [[w:Jersey|Jersey]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Transoceanic Maritime Company]]
|-
! style="background: #f8f9fb;"| Operator
| [[Belle Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
1dce9f07ffe4493256f2edb2a5e6fdd621e9410d
RMS Belle of England
0
152
317
2023-10-01T09:27:36Z
Reverie
2
Reverie moved page [[RMS Belle of England]] to [[RMS Belle of England (1937)]]
wikitext
text/x-wiki
#REDIRECT [[RMS Belle of England (1937)]]
aa324c9b1b777223fd8cfae4ac97e9bc71980332
Transoceanic Maritime Company
0
153
319
2023-10-01T09:33:36Z
Reverie
2
Placeholder
wikitext
text/x-wiki
The '''Transoceanic Maritime Company''' is a British shipping and [[cruise line]] based at [[W:Southampton|Southampton]], England. Since 2002, Transoceanic Maritime Company has been registered in [[w:Hamilton, Bermuda]].
afb3a14516e015ff1823a28af4f75f786eac5b6e
320
319
2023-10-01T09:33:58Z
Reverie
2
wikitext
text/x-wiki
The '''Transoceanic Maritime Company''' is a British shipping and [[w:cruise line]] based at [[W:Southampton|Southampton]], England. Since 2002, Transoceanic Maritime Company has been registered in [[w:Hamilton, Bermuda]].
ad66b9a66dd1094e719b6771d73a3e2493fe49a9
321
320
2023-10-01T09:34:25Z
Reverie
2
wikitext
text/x-wiki
The '''Transoceanic Maritime Company''' is a British shipping and [[w:cruise line|cruise line]] based at [[W:Southampton|Southampton]], England. Since 2002, Transoceanic Maritime Company has been registered in [[w:Hamilton, Bermuda]].
05ad6b580dcb2690c70e23970edc23f4f39cc126
322
321
2023-10-01T09:34:46Z
Reverie
2
wikitext
text/x-wiki
The '''Transoceanic Maritime Company''' is a British shipping and [[w:cruise line|cruise line]] based at [[W:Southampton|Southampton]], England. Since 2002, Transoceanic Maritime Company has been registered in [[w:Hamilton, Bermuda| Hamilton, Bermuda]].
5134895ddfe40c41b9d192f0f7b26d9c7a2888a8
325
322
2023-10-02T00:28:30Z
Reverie
2
wikitext
text/x-wiki
The '''Transoceanic Maritime Company''' is a British shipping and [[w:cruise line|cruise line]] based at [[W:Southampton|Southampton]], England. Since 2002, Transoceanic Maritime Company has been registered in [[w:Hamilton, Bermuda| Hamilton, Bermuda]].
{{Placeholder}}
0a59e1d190f79c2a7549e6c56bedb3a690f93de3
Template:Placeholder
10
154
324
2023-10-02T00:26:57Z
Reverie
2
Created page with "{| style="border-spacing: 2px; border: 1px solid darkgray;" |- | This article is a placeholder. It is meant to fill an empty red link. Its completed article may be written soon. | ''Please write a basic summary of the subject, do not just insert this template'' |}"
wikitext
text/x-wiki
{| style="border-spacing: 2px; border: 1px solid darkgray;"
|-
| This article is a placeholder. It is meant to fill an empty red link. Its completed article may be written soon.
| ''Please write a basic summary of the subject, do not just insert this template''
|}
1bcfe5e23132e1b75b1f005be7e243ce684089c1
326
324
2023-10-02T00:29:55Z
Reverie
2
wikitext
text/x-wiki
{| style="border-spacing: 2px; border: 1px solid darkgray;"
|-
| This article is a placeholder. It is meant to fill an empty red link. Its completed article may be written soon.
| ''Please write a basic summary of the subject, do not just insert this template''
|}
[[Category:Placeholder articles]]
[[Category:Stub]]
9cb91ffdddd3523efbff1b9e1ff8911701e13ca3
Category:Placeholder articles
14
155
327
2023-10-02T00:32:21Z
Reverie
2
Created page with "'''Placeholder articles''' are meant to fill in an empty red link. Red links are articles that hasn't been written yet. Please make sure that placeholder articles will be completed sooner or later."
wikitext
text/x-wiki
'''Placeholder articles''' are meant to fill in an empty red link. Red links are articles that hasn't been written yet. Please make sure that placeholder articles will be completed sooner or later.
eeb2a1e7170f4b3710bba715b222cf6ef181c1a0
Template:Strong
10
156
329
328
2023-10-02T00:40:41Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
<strong {{#if:{{{role|}}}|role="{{{role}}}"}} {{#if:{{{class|}}}|class="{{{class}}}"}} {{#if:{{{id|}}}|id="{{{id}}}"}} {{#if:{{{style|}}}|style="{{{style}}}"}} {{#if:{{{title|}}}|title="{{{title}}}"}}>{{{1}}}</strong><noinclude>
{{documentation}}
<!-- Add cats and interwikis to the /doc subpage, not here! -->
</noinclude>
a6c6d3b520e2018e19376e2f0e1a72801336d1df
Module:Text
828
157
331
330
2023-10-02T00:40:42Z
Reverie
2
1 revision imported
Scribunto
text/plain
local yesNo = require("Module:Yesno")
local Text = { serial = "2022-07-21",
suite = "Text" }
--[=[
Text utilities
]=]
-- local globals
local PatternCJK = false
local PatternCombined = false
local PatternLatin = false
local PatternTerminated = false
local QuoteLang = false
local QuoteType = false
local RangesLatin = false
local SeekQuote = false
local function initLatinData()
if not RangesLatin then
RangesLatin = { { 7, 687 },
{ 7531, 7578 },
{ 7680, 7935 },
{ 8194, 8250 } }
end
if not PatternLatin then
local range
PatternLatin = "^["
for i = 1, #RangesLatin do
range = RangesLatin[ i ]
PatternLatin = PatternLatin ..
mw.ustring.char( range[ 1 ], 45, range[ 2 ] )
end -- for i
PatternLatin = PatternLatin .. "]*$"
end
end
local function initQuoteData()
-- Create quote definitions
if not QuoteLang then
QuoteLang =
{ af = "bd",
ar = "la",
be = "labd",
bg = "bd",
ca = "la",
cs = "bd",
da = "bd",
de = "bd",
dsb = "bd",
et = "bd",
el = "lald",
en = "ld",
es = "la",
eu = "la",
-- fa = "la",
fi = "rd",
fr = "laSPC",
ga = "ld",
he = "ldla",
hr = "bd",
hsb = "bd",
hu = "bd",
hy = "labd",
id = "rd",
is = "bd",
it = "ld",
ja = "x300C",
ka = "bd",
ko = "ld",
lt = "bd",
lv = "bd",
nl = "ld",
nn = "la",
no = "la",
pl = "bdla",
pt = "lald",
ro = "bdla",
ru = "labd",
sk = "bd",
sl = "bd",
sq = "la",
sr = "bx",
sv = "rd",
th = "ld",
tr = "ld",
uk = "la",
zh = "ld",
["de-ch"] = "la",
["en-gb"] = "lsld",
["en-us"] = "ld",
["fr-ch"] = "la",
["it-ch"] = "la",
["pt-br"] = "ldla",
["zh-tw"] = "x300C",
["zh-cn"] = "ld" }
end
if not QuoteType then
QuoteType =
{ bd = { { 8222, 8220 }, { 8218, 8217 } },
bdla = { { 8222, 8220 }, { 171, 187 } },
bx = { { 8222, 8221 }, { 8218, 8217 } },
la = { { 171, 187 }, { 8249, 8250 } },
laSPC = { { 171, 187 }, { 8249, 8250 }, true },
labd = { { 171, 187 }, { 8222, 8220 } },
lald = { { 171, 187 }, { 8220, 8221 } },
ld = { { 8220, 8221 }, { 8216, 8217 } },
ldla = { { 8220, 8221 }, { 171, 187 } },
lsld = { { 8216, 8217 }, { 8220, 8221 } },
rd = { { 8221, 8221 }, { 8217, 8217 } },
x300C = { { 0x300C, 0x300D },
{ 0x300E, 0x300F } } }
end
end -- initQuoteData()
local function fiatQuote( apply, alien, advance )
-- Quote text
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code
-- advance -- number, with level 1 or 2
local r = apply and tostring(apply) or ""
alien = alien or "en"
advance = tonumber(advance) or 0
local suite
initQuoteData()
local slang = alien:match( "^(%l+)-" )
suite = QuoteLang[alien] or slang and QuoteLang[slang] or QuoteLang["en"]
if suite then
local quotes = QuoteType[ suite ]
if quotes then
local space
if quotes[ 3 ] then
space = " "
else
space = ""
end
quotes = quotes[ advance ]
if quotes then
r = mw.ustring.format( "%s%s%s%s%s",
mw.ustring.char( quotes[ 1 ] ),
space,
apply,
space,
mw.ustring.char( quotes[ 2 ] ) )
end
else
mw.log( "fiatQuote() " .. suite )
end
end
return r
end -- fiatQuote()
Text.char = function ( apply, again, accept )
-- Create string from codepoints
-- Parameter:
-- apply -- table (sequence) with numerical codepoints, or nil
-- again -- number of repetitions, or nil
-- accept -- true, if no error messages to be appended
-- Returns: string
local r = ""
apply = type(apply) == "table" and apply or {}
again = math.floor(tonumber(again) or 1)
if again < 1 then
return ""
end
local bad = { }
local codes = { }
for _, v in ipairs( apply ) do
local n = tonumber(v)
if not n or (n < 32 and n ~= 9 and n ~= 10) then
table.insert(bad, tostring(v))
else
table.insert(codes, math.floor(n))
end
end
if #bad > 0 then
if not accept then
r = tostring( mw.html.create( "span" )
:addClass( "error" )
:wikitext( "bad codepoints: " .. table.concat( bad, " " )) )
end
return r
end
if #codes > 0 then
r = mw.ustring.char( unpack( codes ) )
if again > 1 then
r = r:rep(again)
end
end
return r
end -- Text.char()
local function trimAndFormat(args, fmt)
local result = {}
if type(args) ~= 'table' then
args = {args}
end
for _, v in ipairs(args) do
v = mw.text.trim(tostring(v))
if v ~= "" then
table.insert(result,fmt and mw.ustring.format(fmt, v) or v)
end
end
return result
end
Text.concatParams = function ( args, apply, adapt )
-- Concat list items into one string
-- Parameter:
-- args -- table (sequence) with numKey=string
-- apply -- string (optional); separator (default: "|")
-- adapt -- string (optional); format including "%s"
-- Returns: string
local collect = { }
return table.concat(trimAndFormat(args,adapt), apply or "|")
end -- Text.concatParams()
Text.containsCJK = function ( s )
-- Is any CJK code within?
-- Parameter:
-- s -- string
-- Returns: true, if CJK detected
s = s and tostring(s) or ""
if not patternCJK then
patternCJK = mw.ustring.char( 91,
4352, 45, 4607,
11904, 45, 42191,
43072, 45, 43135,
44032, 45, 55215,
63744, 45, 64255,
65072, 45, 65103,
65381, 45, 65500,
131072, 45, 196607,
93 )
end
return mw.ustring.find( s, patternCJK ) ~= nil
end -- Text.containsCJK()
Text.removeDelimited = function (s, prefix, suffix)
-- Remove all text in s delimited by prefix and suffix (inclusive)
-- Arguments:
-- s = string to process
-- prefix = initial delimiter
-- suffix = ending delimiter
-- Returns: stripped string
s = s and tostring(s) or ""
prefix = prefix and tostring(prefix) or ""
suffix = suffix and tostring(suffix) or ""
local prefixLen = mw.ustring.len(prefix)
local suffixLen = mw.ustring.len(suffix)
if prefixLen == 0 or suffixLen == 0 then
return s
end
local i = s:find(prefix, 1, true)
local r = s
local j
while i do
j = r:find(suffix, i + prefixLen)
if j then
r = r:sub(1, i - 1)..r:sub(j+suffixLen)
else
r = r:sub(1, i - 1)
end
i = r:find(prefix, 1, true)
end
return r
end
Text.getPlain = function ( adjust )
-- Remove wikisyntax from string, except templates
-- Parameter:
-- adjust -- string
-- Returns: string
local r = Text.removeDelimited(adjust,"<!--","-->")
r = r:gsub( "(</?%l[^>]*>)", "" )
:gsub( "'''", "" )
:gsub( "''", "" )
:gsub( " ", " " )
return r
end -- Text.getPlain()
Text.isLatinRange = function (s)
-- Are characters expected to be latin or symbols within latin texts?
-- Arguments:
-- s = string to analyze
-- Returns: true, if valid for latin only
s = s and tostring(s) or "" --- ensure input is always string
initLatinData()
return mw.ustring.match(s, PatternLatin) ~= nil
end -- Text.isLatinRange()
Text.isQuote = function ( s )
-- Is this character any quotation mark?
-- Parameter:
-- s = single character to analyze
-- Returns: true, if s is quotation mark
s = s and tostring(s) or ""
if s == "" then
return false
end
if not SeekQuote then
SeekQuote = mw.ustring.char( 34, -- "
39, -- '
171, -- laquo
187, -- raquo
8216, -- lsquo
8217, -- rsquo
8218, -- sbquo
8220, -- ldquo
8221, -- rdquo
8222, -- bdquo
8249, -- lsaquo
8250, -- rsaquo
0x300C, -- CJK
0x300D, -- CJK
0x300E, -- CJK
0x300F ) -- CJK
end
return mw.ustring.find( SeekQuote, s, 1, true ) ~= nil
end -- Text.isQuote()
Text.listToText = function ( args, adapt )
-- Format list items similar to mw.text.listToText()
-- Parameter:
-- args -- table (sequence) with numKey=string
-- adapt -- string (optional); format including "%s"
-- Returns: string
return mw.text.listToText(trimAndFormat(args, adapt))
end -- Text.listToText()
Text.quote = function ( apply, alien, advance )
-- Quote text
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code, or nil
-- advance -- number, with level 1 or 2, or nil
-- Returns: quoted string
apply = apply and tostring(apply) or ""
local mode, slang
if type( alien ) == "string" then
slang = mw.text.trim( alien ):lower()
else
slang = mw.title.getCurrentTitle().pageLanguage
if not slang then
-- TODO FIXME: Introduction expected 2017-04
slang = mw.language.getContentLanguage():getCode()
end
end
if advance == 2 then
mode = 2
else
mode = 1
end
return fiatQuote( mw.text.trim( apply ), slang, mode )
end -- Text.quote()
Text.quoteUnquoted = function ( apply, alien, advance )
-- Quote text, if not yet quoted and not empty
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code, or nil
-- advance -- number, with level 1 or 2, or nil
-- Returns: string; possibly quoted
local r = mw.text.trim( apply and tostring(apply) or "" )
local s = mw.ustring.sub( r, 1, 1 )
if s ~= "" and not Text.isQuote( s, advance ) then
s = mw.ustring.sub( r, -1, 1 )
if not Text.isQuote( s ) then
r = Text.quote( r, alien, advance )
end
end
return r
end -- Text.quoteUnquoted()
Text.removeDiacritics = function ( adjust )
-- Remove all diacritics
-- Parameter:
-- adjust -- string
-- Returns: string; all latin letters should be ASCII
-- or basic greek or cyrillic or symbols etc.
local cleanup, decomposed
if not PatternCombined then
PatternCombined = mw.ustring.char( 91,
0x0300, 45, 0x036F,
0x1AB0, 45, 0x1AFF,
0x1DC0, 45, 0x1DFF,
0xFE20, 45, 0xFE2F,
93 )
end
decomposed = mw.ustring.toNFD( adjust and tostring(adjust) or "" )
cleanup = mw.ustring.gsub( decomposed, PatternCombined, "" )
return mw.ustring.toNFC( cleanup )
end -- Text.removeDiacritics()
Text.sentenceTerminated = function ( analyse )
-- Is string terminated by dot, question or exclamation mark?
-- Quotation, link termination and so on granted
-- Parameter:
-- analyse -- string
-- Returns: true, if sentence terminated
local r
if not PatternTerminated then
PatternTerminated = mw.ustring.char( 91,
12290,
65281,
65294,
65311 )
.. "!%.%?…][\"'%]‹›«»‘’“”]*$"
end
if mw.ustring.find( analyse, PatternTerminated ) then
r = true
else
r = false
end
return r
end -- Text.sentenceTerminated()
Text.ucfirstAll = function ( adjust)
-- Capitalize all words
-- Arguments:
-- adjust = string to adjust
-- Returns: string with all first letters in upper case
adjust = adjust and tostring(adjust) or ""
local r = mw.text.decode(adjust,true)
local i = 1
local c, j, m
m = (r ~= adjust)
r = " "..r
while i do
i = mw.ustring.find( r, "%W%l", i )
if i then
j = i + 1
c = mw.ustring.upper( mw.ustring.sub( r, j, j ) )
r = string.format( "%s%s%s",
mw.ustring.sub( r, 1, i ),
c,
mw.ustring.sub( r, i + 2 ) )
i = j
end
end -- while i
r = r:sub( 2 )
if m then
r = mw.text.encode(r)
end
return r
end -- Text.ucfirstAll()
Text.uprightNonlatin = function ( adjust )
-- Ensure non-italics for non-latin text parts
-- One single greek letter might be granted
-- Precondition:
-- adjust -- string
-- Returns: string with non-latin parts enclosed in <span>
local r
initLatinData()
if mw.ustring.match( adjust, PatternLatin ) then
-- latin only, horizontal dashes, quotes
r = adjust
else
local c
local j = false
local k = 1
local m = false
local n = mw.ustring.len( adjust )
local span = "%s%s<span dir='auto' style='font-style:normal'>%s</span>"
local flat = function ( a )
-- isLatin
local range
for i = 1, #RangesLatin do
range = RangesLatin[ i ]
if a >= range[ 1 ] and a <= range[ 2 ] then
return true
end
end -- for i
end -- flat()
local focus = function ( a )
-- char is not ambivalent
local r = ( a > 64 )
if r then
r = ( a < 8192 or a > 8212 )
else
r = ( a == 38 or a == 60 ) -- '&' '<'
end
return r
end -- focus()
local form = function ( a )
return string.format( span,
r,
mw.ustring.sub( adjust, k, j - 1 ),
mw.ustring.sub( adjust, j, a ) )
end -- form()
r = ""
for i = 1, n do
c = mw.ustring.codepoint( adjust, i, i )
if focus( c ) then
if flat( c ) then
if j then
if m then
if i == m then
-- single greek letter.
j = false
end
m = false
end
if j then
local nx = i - 1
local s = ""
for ix = nx, 1, -1 do
c = mw.ustring.sub( adjust, ix, ix )
if c == " " or c == "(" then
nx = nx - 1
s = c .. s
else
break -- for ix
end
end -- for ix
r = form( nx ) .. s
j = false
k = i
end
end
elseif not j then
j = i
if c >= 880 and c <= 1023 then
-- single greek letter?
m = i + 1
else
m = false
end
end
elseif m then
m = m + 1
end
end -- for i
if j and ( not m or m < n ) then
r = form( n )
else
r = r .. mw.ustring.sub( adjust, k )
end
end
return r
end -- Text.uprightNonlatin()
Text.test = function ( about )
local r
if about == "quote" then
initQuoteData()
r = { }
r.QuoteLang = QuoteLang
r.QuoteType = QuoteType
end
return r
end -- Text.test()
-- Export
local p = { }
for _, func in ipairs({'containsCJK','isLatinRange','isQuote','sentenceTerminated'}) do
p[func] = function (frame)
return Text[func]( frame.args[ 1 ] or "" ) and "1" or ""
end
end
for _, func in ipairs({'getPlain','removeDiacritics','ucfirstAll','uprightNonlatin'}) do
p[func] = function (frame)
return Text[func]( frame.args[ 1 ] or "" )
end
end
function p.char( frame )
local params = frame:getParent().args
local story = params[ 1 ]
local codes, lenient, multiple
if not story then
params = frame.args
story = params[ 1 ]
end
if story then
local items = mw.text.split( mw.text.trim(story), "%s+" )
if #items > 0 then
local j
lenient = (yesNo(params.errors) == false)
codes = { }
multiple = tonumber( params[ "*" ] )
for _, v in ipairs( items ) do
j = tonumber((v:sub( 1, 1 ) == "x" and "0" or "") .. v)
table.insert( codes, j or v )
end
end
end
return Text.char( codes, multiple, lenient )
end
function p.concatParams( frame )
local args
local template = frame.args.template
if type( template ) == "string" then
template = mw.text.trim( template )
template = ( template == "1" )
end
if template then
args = frame:getParent().args
else
args = frame.args
end
return Text.concatParams( args,
frame.args.separator,
frame.args.format )
end
function p.listToFormat(frame)
local lists = {}
local pformat = frame.args["format"]
local sep = frame.args["sep"] or ";"
-- Parameter parsen: Listen
for k, v in pairs(frame.args) do
local knum = tonumber(k)
if knum then lists[knum] = v end
end
-- Listen splitten
local maxListLen = 0
for i = 1, #lists do
lists[i] = mw.text.split(lists[i], sep)
if #lists[i] > maxListLen then maxListLen = #lists[i] end
end
-- Ergebnisstring generieren
local result = ""
local result_line = ""
for i = 1, maxListLen do
result_line = pformat
for j = 1, #lists do
result_line = mw.ustring.gsub(result_line, "%%s", lists[j][i], 1)
end
result = result .. result_line
end
return result
end
function p.listToText( frame )
local args
local template = frame.args.template
if type( template ) == "string" then
template = mw.text.trim( template )
template = ( template == "1" )
end
if template then
args = frame:getParent().args
else
args = frame.args
end
return Text.listToText( args, frame.args.format )
end
function p.quote( frame )
local slang = frame.args[2]
if type( slang ) == "string" then
slang = mw.text.trim( slang )
if slang == "" then
slang = false
end
end
return Text.quote( frame.args[ 1 ] or "",
slang,
tonumber( frame.args[3] ) )
end
function p.quoteUnquoted( frame )
local slang = frame.args[2]
if type( slang ) == "string" then
slang = mw.text.trim( slang )
if slang == "" then
slang = false
end
end
return Text.quoteUnquoted( frame.args[ 1 ] or "",
slang,
tonumber( frame.args[3] ) )
end
function p.zip(frame)
local lists = {}
local seps = {}
local defaultsep = frame.args["sep"] or ""
local innersep = frame.args["isep"] or ""
local outersep = frame.args["osep"] or ""
-- Parameter parsen
for k, v in pairs(frame.args) do
local knum = tonumber(k)
if knum then lists[knum] = v else
if string.sub(k, 1, 3) == "sep" then
local sepnum = tonumber(string.sub(k, 4))
if sepnum then seps[sepnum] = v end
end
end
end
-- sofern keine expliziten Separatoren angegeben sind, den Standardseparator verwenden
for i = 1, math.max(#seps, #lists) do
if not seps[i] then seps[i] = defaultsep end
end
-- Listen splitten
local maxListLen = 0
for i = 1, #lists do
lists[i] = mw.text.split(lists[i], seps[i])
if #lists[i] > maxListLen then maxListLen = #lists[i] end
end
local result = ""
for i = 1, maxListLen do
if i ~= 1 then result = result .. outersep end
for j = 1, #lists do
if j ~= 1 then result = result .. innersep end
result = result .. (lists[j][i] or "")
end
end
return result
end
function p.failsafe()
return Text.serial
end
p.Text = function ()
return Text
end -- p.Text
return p
07f1fc4d39342fd92bdae1c5463bbfede7eeda1a
Template:Terminate sentence
10
158
333
332
2023-10-02T00:40:44Z
Reverie
2
1 revision imported
wikitext
text/x-wiki
{{{1}}}{{#if:{{#invoke:text|sentenceTerminated|{{{1|}}}}}||{{{2|.}}}}}<noinclude>{{documentation}}</noinclude>
e4142b47b3d7959b82f582bab87ca10768d4d93b
File:Belle of England in Jersey (1939).jpeg
6
160
345
2023-10-02T01:30:12Z
Reverie
2
taken in roblox
wikitext
text/x-wiki
== Summary ==
taken in roblox
0223ce63b9c9260d4f2e86857e67c6a16d57cc00
Home
0
2
347
7
2023-10-02T02:09:57Z
Reverie
2
Protected "[[Home]]": Main page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
wikitext
text/x-wiki
<big>Welcome to Maritime Fiction!</big>
=====What is this?=====
Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company!
=====What do I make here?=====
Feel free to write anything here, ships, captains, shipping lines, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!
=== Start now! ===
[[Special:CreatePage|You can create an article/page by clicking here]]
9c007191f3f0ce22a9ad85e938a7eda334815b28
360
347
2023-10-02T12:41:59Z
Reverie
2
wikitext
text/x-wiki
<big>Welcome to Maritime Fiction!</big>
=====What is this?=====
Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company!
=====What do I make here?=====
Feel free to write anything here, ships, captains, shipping lines, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!
=== Start now! ===
[[Special:CreatePage|You can create an article/page by clicking here]]
[https://marfict.miraheze.org/wiki/Special:RecentChanges?hidebots=1&limit=50&days=7&enhanced=1&urlversion=2 Click here to see recent changes made (new article, article edited, logs, etc.)]
43fad01ba4a95e2c9ddca109f1cdff282ce18ca3
RMS Coral Sea (1922)
0
161
348
2023-10-02T06:43:34Z
TheFictionals
4
First time
wikitext
text/x-wiki
RMS Coral Sea was a British-German ocean liner that was built back in late 1919. She had her maiden voyage on the 26th of July, 1922 in which she crossed from Glasgow to Sydney. She was one of the few ships that were in service during the '''Great Depression'''.
4338a3f279b316a2a2cc29af4212670205d7c225
349
348
2023-10-02T06:54:07Z
TheFictionals
4
wikitext
text/x-wiki
RMS Coral Sea was a British-German ocean liner that was built back in late 1919. She had her maiden voyage on the 26th of July, 1922 in which she crossed from Glasgow to Sydney. She was one of the few ships that were in service during the '''[https://en.wikipedia.org/wiki/Great_Depression_in_the_United_States Great Depression]'''. She was around 244 - 245 meters in length. She had a black hull with a white stripe going around the ship, with three navy blue funnels.
17bb2d5b2291ef9cc90bf4e3baf73bdff69e968b
351
349
2023-10-02T10:37:08Z
TheFictionals
4
Added photos and more details
wikitext
text/x-wiki
The Coral Sea or RMS Coral Sea was a British-German ocean liner that was built back in late 1919. She had her maiden voyage on the 26th of July, 1922 in which she crossed from Glasgow to Sydney, her regular crossing. She was one of the few ships that were in service during the '''[https://en.wikipedia.org/wiki/Great_Depression_in_the_United_States Great Depression]'''. She was around 244 to 245 meters in length and could accommodate roughly 1900 people. She had a black hull with a white stripe going it, with three tall navy blue funnels.
[[File:Coral Sea in Clyde River.jpg|left|thumb|130x130px|Coral Sea leaving the Clyde Bank, Glasgow (1924, Colorized)]]
In the spring of 1935, the Coral Sea had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named the Rosas or SS Rosas had departed from Wellington, New Zealand and across the Pacific. We don’t know exactly where the ships port of arrival was or when they would arrive there.
The Rosas had to pick up more supplies from Darwin before she could continue her crossing.
edbf0941dae42eb53ade263e875b573ef2a473c2
352
351
2023-10-02T10:55:30Z
TheFictionals
4
Added headings
wikitext
text/x-wiki
== Introduction ==
The Coral Sea or RMS Coral Sea was a British-German ocean liner that was built back in late 1919. She had her maiden voyage on the 26th of July, 1922 in which she crossed from Glasgow to Sydney, her regular crossing. She was one of the few ships that were in service during the '''[https://en.wikipedia.org/wiki/Great_Depression_in_the_United_States Great Depression]'''.
== Design and Structure ==
She was around 244 to 245 meters in length and could accommodate roughly 1900 people. She had a black hull with a white stripe going it, with three tall navy blue funnels. Her dining saloons, lounges, and main staircases all were the center of attraction. She has four 4-bladed propellers that make her go 23 knots at maximum.
[[File:Coral Sea in Clyde River.jpg|left|thumb|130x130px|alt=Weans |border]]
== The Disaster ==
In the spring of 1935, the Coral Sea had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named the Rosas or SS Rosas had departed from Wellington, New Zealand and across the Pacific. We don’t know exactly where the ships port of arrival was or when they would arrive there. The Rosas had to pick up more supplies from Darwin before she could continue her crossing.
c5e40b4004a834441fe3f9c5059ead9355caccc5
353
352
2023-10-02T11:24:26Z
TheFictionals
4
Removing image
wikitext
text/x-wiki
== Introduction ==
The Coral Sea or RMS Coral Sea was a British-German ocean liner that was built back in late 1919. She had her maiden voyage on the 26th of July, 1922 in which she crossed from Glasgow to Sydney, her regular crossing. She was one of the few ships that were in service during the '''[https://en.wikipedia.org/wiki/Great_Depression_in_the_United_States Great Depression]'''.
== Design and Structure ==
She was around 244 to 245 meters in length and could accommodate roughly 1900 people. She had a black hull with a white stripe going it, with three tall navy blue funnels. Her dining saloons, lounges, and main staircases all were the center of attraction. She has four 4-bladed propellers that make her go 23 knots at maximum.
==The Disaster==
In the spring of 1935, the Coral Sea had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named the Rosas or SS Rosas had departed from Wellington, New Zealand and across the Pacific. We don’t know exactly where the ships port of arrival was or when they would arrive there. The Rosas had to pick up more supplies from Darwin before she could continue her crossing.
5b551c22aad11ebd47c4576767baca13116af9c5
354
353
2023-10-02T11:54:00Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She had her maiden voyage on the 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that was in service during the [[w:Great depression|great depression]]'''
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Operator
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Glascow|Glascow]], Scotland}}}
|}
== Overview ==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe seperating them. Her dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propels her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing.
<ref></ref>
e1fbe7ed43ebbbb37f385fc9e3eab9b859db874b
355
354
2023-10-02T11:54:25Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She had her maiden voyage on the 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that was in service during the [[w:Great depression|great depression]]'''
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Operator
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Glascow|Glascow]], Scotland}}}
|}
== Overview ==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe seperating them. Her dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propels her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing.
<ref></ref>
00054632867a66246a2798e9e5bad8cb23c93bd4
356
355
2023-10-02T11:55:12Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She had her maiden voyage on the 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that was in service during the [[w:Great depression|great depression]]'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Operator
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Glascow|Glascow]], Scotland}}}
|}
== Overview ==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe seperating them. Her dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propels her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing.
e7208d16c789e6dbd6c7c628f28df763d5d08bc3
357
356
2023-10-02T11:56:01Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that was in service during the [[w:Great depression|great depression]]'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Operator
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Glascow|Glascow]], Scotland}}}
|}
== Overview ==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe seperating them. Her dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propels her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing.
da2e2621577f2fa38fa6b66c44224c1979d4a77a
358
357
2023-10-02T11:56:14Z
Reverie
2
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that was in service during the [[w:Great depression|great depression]]'''.
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Operator
| [[Parelian Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Glascow|Glascow]], Scotland}}}
|}
== Overview ==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe seperating them. Her dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propels her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing.
ee4a631d013fe99dac9b4aa9c6df01a045f2035c
359
358
2023-10-02T12:38:41Z
TheFictionals
4
Added chart for info
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that was in service during the [[w:Great depression|great depression]]'''.
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe seperating them. Her dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed.
c865d1a341c3707eda1209a6bd8ccdc2153c2d08
File:Coral Sea in Clyde River.jpg
6
162
350
2023-10-02T06:58:37Z
TheFictionals
4
wikitext
text/x-wiki
Coral Sea leaving Glasgow in 1922
bbff298bc4ca9dc10a270c68825e307dd003a4d4
Template:WIP
10
163
361
2023-10-02T12:46:20Z
Reverie
2
Created page with "{| class="wikitable" |+ '''Work in progress!''' |- | ''This article is a W.I.P., which means that it is not completed yet. | It may be completed soon in the future by its writters.'' |} [[Category:WIP]]"
wikitext
text/x-wiki
{| class="wikitable"
|+ '''Work in progress!'''
|-
| ''This article is a W.I.P., which means that it is not completed yet.
| It may be completed soon in the future by its writters.''
|}
[[Category:WIP]]
a8fc0bb053031c33733f0b9f193ea681f93b2098
362
361
2023-10-02T12:47:24Z
Reverie
2
wikitext
text/x-wiki
{| class="wikitable"
|+ '''Work in progress!'''
|-
| ''This article is a W.I.P., which means that it is not completed yet. It may be completed soon in the future by its writters.'' '''''Please make sure to remove this template when the article is finished.'''''
|}
[[Category:WIP]]
a998a5dfd09d362203b23a6733bfa51ccd08e31c
RMS Coral Sea (1922)
0
161
363
359
2023-10-02T12:48:47Z
Reverie
2
wikitext
text/x-wiki
{{WIP}}
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that was in service during the [[w:Great depression|great depression]]'''.
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe seperating them. Her dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed.
38d598eccd8bde7287382817bc56ffd9990593da
373
363
2023-10-02T13:28:44Z
TheFictionals
4
Added testimonies and a conclusion we are done
wikitext
text/x-wiki
{{WIP}}
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''Café Garden''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
== Evidence and Research ==
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only that specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
== Testimonies ==
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
== Conclusion ==
After 90 years, she doesn’t seem to be in good status anymore. There had been attempts to salvage parts of the wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows? Maybe we could try to do it today.
ad654f7ab02f4024d7a669fff7aca0076b6764e2
375
373
2023-10-02T13:59:13Z
Reverie
2
wikitext
text/x-wiki
{{WIP}}
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" | [[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
==The Disaster==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''Café Garden''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
== Evidence and Research ==
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only that specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
After 90 years, she doesn’t seem to be in good status anymore. There had been attempts to salvage parts of the wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
== Testimonies ==
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
b085a82f2e97280a20aa1aa1ef202413f375d6d0
392
375
2023-10-03T10:17:35Z
112.201.133.57
0
Removed WIP
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" |[[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" |<small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! colspan="2" style="background: #CECEF2;" |{{{subj|History}}}
|-
! colspan="2" style="background: #bfbfe3;" |{{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;" |Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
==The Disaster ==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''Café Garden''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
==Evidence and Research==
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only that specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
After 90 years, she doesn’t seem to be in good status anymore. There had been attempts to salvage parts of the wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
==Testimonies==
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
afac1fb0bff82deba79c4e7b87c00a0c044aaf9a
393
392
2023-10-03T10:29:43Z
TheFictionals
4
Adding a new heading
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" |[[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" |<small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! colspan="2" style="background: #CECEF2;" |{{{subj|History}}}
|-
! colspan="2" style="background: #bfbfe3;" |{{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;" |Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
== Background ==
==The Disaster ==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''Café Garden''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
==Evidence and Research==
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only that specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
After 90 years, she doesn’t seem to be in good status anymore. There had been attempts to salvage parts of the wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
==Testimonies==
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
bcebf7e336e16a9358855c02de250044ea504a23
394
393
2023-10-03T10:42:15Z
TheFictionals
4
Added construction info
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" |[[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" |<small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! colspan="2" style="background: #CECEF2;" |{{{subj|History}}}
|-
! colspan="2" style="background: #bfbfe3;" |{{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;" |Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
== Construction ==
Her date of construction was on October 23, 1919. She was built as Hull No. 287 at John Brown’s Shipyard in Clydebank, Glasgow. She was the first ship to be built among the four [[Coral-class]] liners. Their names would be “Coral” followed by something related to the word “Sea”. She went all the way down to G Deck, the lowest deck for crew members (excluding stokers) to go. It was also where they kept the cargo and food supplies. For passengers, they could only access Boat Deck to E Deck. Her keel lay
==The Disaster ==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''Café Garden''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
==Evidence and Research==
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only that specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
After 90 years, she doesn’t seem to be in good status anymore. There had been attempts to salvage parts of the wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
==Testimonies==
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
d91651ebe4a91e62c27cf09f2115c7386392499e
395
394
2023-10-03T10:55:11Z
TheFictionals
4
Finished construction info
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" |[[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" |<small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! colspan="2" style="background: #CECEF2;" |{{{subj|History}}}
|-
! colspan="2" style="background: #bfbfe3;" |{{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;" |Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and main staircases were the center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
== Construction ==
Her date of construction was on October 23, 1919. She was built as Hull No. 287 at John Brown’s Shipyard in Clydebank, Glasgow. She was the first ship to be built among the four [[Coral-class]] liners. Their names would be “Coral” followed by something related to the word “Sea”. She went all the way down to G Deck, the lowest deck for crew members (excluding stokers) to go. It was also where they kept the cargo and food supplies. For passengers, they could only access Boat Deck to E Deck. Her keel was laid on the No. 2 slipway of the shipyard.
She was launched and christened on May 4, 1921. Her sea trials began a month later. On July 26, 1922, she began her maiden voyage. At that point, her first sister ship began her construction; the ''[[Coral Marine]].'' It then followed with the ''[[Coral Aquatic]]'' and the ''[[Coral Trench]]''.
With the four ships built, the operators called them “''[[The Parelian’s Big Four]]''”.
==The Disaster ==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''Rosas'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''Café Garden''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
==Evidence and Research==
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only tha specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
After 90 years, she doesn’t seem to be in good status anymore. There had been attempts to salvage parts of the wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
==Testimonies==
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
7f13e3d49a3bb80416f6c8ca96dd413766d626f9
396
395
2023-10-03T11:02:36Z
TheFictionals
4
Subheadings added for comprehension
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" |[[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" |<small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! colspan="2" style="background: #CECEF2;" |{{{subj|History}}}
|-
! colspan="2" style="background: #bfbfe3;" |{{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;" |Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and staircases were the main center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
== Construction ==
Her date of construction was on October 23, 1919. She was built as Hull No. 287 at John Brown’s Shipyard in Clydebank, Glasgow. She was the first ship to be built among the four [[Coral-class]] liners. Their names would be “Coral” followed by something related to the word “Sea”. She went all the way down to G Deck, the lowest deck for crew members (excluding stokers) to go. It was also where they kept the cargo and food supplies. For passengers, they could only access Boat Deck to E Deck. Her keel was laid on the No. 2 slipway of the shipyard.
She was launched and christened on May 4, 1921. Her sea trials began a month later. On July 26, 1922, she began her maiden voyage. At that point, her first sister ship began her construction; the ''[[Coral Marine]].'' It then followed with the ''[[Coral Aquatic]]'' and the ''[[Coral Trench]]''.
With the four ships built, the operators called them “''[[The Parelian’s Big Four]]''”.
==The Disaster ==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''[[Rosas]]'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''[[Café Garden]]''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
==Evidence and Research==
=== Studies & Clues ===
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only tha specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
=== The Wreck & Salvaging Plans ===
After 90 years, she doesn’t seem to be in good status anymore. She lay on her side with her stern crooked. Her decks above were severely damaged, and they came off like someone ripping a sheet of paper in half. There were debris from the lifeboats that got crushed by the aft most funnel. Pieces of glass scattered around the interior. But, there had been attempts to salvage parts of her wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
==Testimonies==
=== Captain ===
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
=== Passengers ===
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
4529ea0ebdd44f85bb4469af5c3d0c74095e9cc4
397
396
2023-10-03T11:03:57Z
TheFictionals
4
Changed grammar issues
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" |[[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" |<small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! colspan="2" style="background: #CECEF2;" |{{{subj|History}}}
|-
! colspan="2" style="background: #bfbfe3;" |{{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;" |Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and staircases were the main center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
== Construction ==
Her date of construction was on October 23, 1919. She was built as Hull No. 287 at John Brown’s Shipyard in Clydebank, Glasgow. She was the first ship to be built among the four [[Coral-class]] liners. Their names would be “Coral” followed by something related to the word “Sea”. She went all the way down to G Deck, the lowest deck for crew members (excluding stokers) to go. It was also where they kept the cargo and food supplies. For passengers, they could only access Boat Deck to E Deck. Her keel was laid on the No. 2 slipway of the shipyard.
She was launched and christened on May 4, 1921. Her sea trials began a month later. On July 26, 1922, she began her maiden voyage. At that point, her first sister ship began her construction; the ''[[Coral Marine]].'' It then followed with the ''[[Coral Aquatic]]'' and the ''[[Coral Trench]]''.
With the four ships built, the operators called them “''[[The Parelian’s Big Four]]''”.
==The Disaster ==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''[[Rosas]]'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''[[Café Garden]]''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
==Evidence and Research==
=== Studies & Clues ===
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only that specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
=== The Wreck & Salvaging Plans ===
After 90 years, she doesn’t seem to be in good status anymore. She lay on her side with her stern crooked. Her decks above were severely damaged, and they came off like someone ripping a sheet of paper in half. There were debris from the lifeboats that got crushed by the aft most funnel. Pieces of glass scattered around the interior. But, there had been attempts to salvage parts of her wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
==Testimonies==
=== Captain ===
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
=== Passengers ===
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
87610a70d34f1df11d0d9fb41517819bc6ccb629
398
397
2023-10-03T11:05:13Z
TheFictionals
4
Changed sentence made it compund
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" |[[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" |<small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! colspan="2" style="background: #CECEF2;" |{{{subj|History}}}
|-
! colspan="2" style="background: #bfbfe3;" |{{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;" |Owner
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-blue with a white stripe separating them, and metal grey ventilation. Her extravagant dining saloons, lounges, and staircases were the main center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
== Construction ==
Her date of construction was on October 23, 1919. She was built as Hull No. 287 at John Brown’s Shipyard in Clydebank, Glasgow. She was the first ship to be built among the four [[Coral-class]] liners. Their names would be “Coral” followed by something related to the word “Sea”. She went all the way down to G Deck, the lowest deck for crew members (excluding stokers) to go. It was also where they kept the cargo and food supplies. For passengers, they could only access Boat Deck to E Deck. Her keel was laid on the No. 2 slipway of the shipyard.
She was launched and christened on May 4, 1921. Her sea trials began a month later. On July 26, 1922, she began her maiden voyage. At that point, her first sister ship began her construction; the ''[[Coral Marine]].'' It then followed with the ''[[Coral Aquatic]]'' and the ''[[Coral Trench]]''.
With the four ships built, the operators called them “''[[The Parelian’s Big Four]]''”.
==The Disaster ==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''[[Rosas]]'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''[[Café Garden]]''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
==Evidence and Research==
=== Studies & Clues ===
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only that specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
=== The Wreck & Salvaging Plans ===
After 90 years, she doesn’t seem to be in good status anymore. She lay on her side with her stern crooked. Her decks above were severely damaged, and they came off like someone ripping a sheet of paper in half. There were debris from the lifeboats that got crushed by the aft most funnel, and shards of glass scattered around. And really, there had been attempts to salvage parts of her wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
==Testimonies==
=== Captain ===
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
=== Passengers ===
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
b7cbe248124d97057e148d734ab429363fbe7439
401
398
2023-10-07T08:20:12Z
112.201.129.118
0
added some more details to info
wikitext
text/x-wiki
'''RMS ''Coral Sea''''' was a British-German ocean liner that was built in late 1919. She was launched in 1921 and had her maiden voyage on 26 July 1922 in which she crossed from Glasgow to Sydney, her regular route. She was one of the few ships in the [[Parelian Line]] fleet that were in service during the [[w:Great depression|great depression]]'''.'''
{{DISPLAYTITLE:RMS ''Coral Sea'' (1922)}}
{| class="wikitable"
! colspan="2" |[[File:{{{img|Coral Sea in Clyde River.jpg}}}|300px]]
|-
| colspan="2" style="text-align: center" |<small>{{{capt|''Coral Sea'' at the [[w: Clyde River|Clyde River]]}}}</small>
|-
! colspan="2" style="background: #CECEF2;" |{{{subj|History}}}
|-
! colspan="2" style="background: #bfbfe3;" |{{{subj|[[w:United Kingdom|United Kingdom]], [[w:German Empire|Germany]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;" |Builder Company
| [[Maritime Industry Company]]
|-
! style="background: #f8f9fb;" |Operator
|[[Parelian Line]]
|-
! style="background: #f8f9fb;" |Port of Registry
|{{{registry|[[w:Glasgow|Glasgow]], Scotland}}}
|}
==Overview==
The ''Coral Sea'' was 245 meters in length and could accommodate 1900 passengers. She was painted in the traditional Parelian livery; a black hull with a white sheer line, three tall funnels painted in black-navy blue with a white stripe separating them with metal grey ventilation around the decks. Her extravagant dining saloons, lounges, and staircases were the main center of attraction. She has four 4-bladed propellers that propel her at 23 knots maximum.
== Construction ==
Her date of construction was on October 23, 1919. She was built as Hull No. 287 at John Brown’s Shipyard in Clydebank, Glasgow. She was the first ship to be built among the four [[Coral-class]] liners. Their names would be “Coral” followed by something related to the word “Sea”. She went all the way down to G Deck, the lowest deck crew members (excluding stokers) could go. which was also where they kept the cargo and food supplies. For passengers on the other hand, they could only go from Boat Deck down to E Deck. Her keel was laid on the No. 2 slipway of the shipyard.
She was launched and christened on May 4, 1921, with her sea trials beginning a month later. On July 26, 1922, she began her maiden voyage, and at that point of time, her first sister ship began construction; the ''[[Coral Marine]].'' It then followed with the ''[[Coral Aquatic]]'' and the ''[[Coral Trench]]''.
With the four ships built, the operators called them; “''[[The Parelian’s Big Four]]''”. The nickname for the fleet was used the most ever in the company
==The Disaster ==
In the spring of 1935, the ''Coral Sea'' had made her 32nd crossing and yet her last crossing ever with 1915 people on board. In the meantime, a cargo-passenger vessel named ''[[Rosas]]'' had departed from Wellington, New Zealand and across the Pacific. ''Rosas'' had to pick up more supplies from Darwin before she could continue her crossing. With fog rolling over the area, the two ships were unknowingly heading towards each other at full speed. At around 4 in the afternoon, the ''Rosas'' collided with the ''Coral Sea'', in between funnels 2 and 3, just aft of the port ''[[Café Garden]]''. With that, she sunk within 1 hour and 47 minutes, in which, unfortunately, nearly half of the people onboard died. The ''Rosas'' experienced severe damage, and had to be tugged back to Wellington.
==Evidence and Research==
=== Studies & Clues ===
Years passed, and researchers had found the wreck in 1978. They then began to gather some pieces of the ship to identify how the ship, with a more sturdy hull, could sink. It was later found out that the plating at the collision site were weakened. Not only that specific area, but there were some plates that were weakened too. The cause of that is unknown, as it could have been something or someone. And with further speculation, most of the furniture, decks, pottery, doors, etcetera, were all bent, and shattered.
=== The Wreck & Salvaging Plans ===
After 90 years, she doesn’t seem to be in good status anymore. She lay on her side with her stern crooked. Her decks above were severely damaged, and they came off like someone ripping a sheet of paper in half. There were debris from the lifeboats that got crushed by the aft most funnel, and shards of glass scattered around. And really, there had been attempts to salvage parts of her wreck, but that wouldn’t work due to the currents and her condition. Most likely, it’s best to let her rest on the seabed rather to salvage it for a memorial. Who knows?
==Testimonies==
=== Captain ===
Testimonies from the captain, Otto Schülz, were that minutes after the ship had been hit, the power completely went off. 1st Officer, Troph Gibson reported to him, that he had heard crowds panicking and screaming below deck, trying to scramble up staircases as the ship plunged into darkness.
=== Passengers ===
Another testimony from a 2nd class passenger, Marge Aphile said that she heard a loud rumble from the ship. Seconds later, she saw the aft most funnel, burst into flames and collapse into the sea. She was on Lifeboat #6 when she saw what happened.
One testimony from a 1st class passenger, Francis Harisson said he was trying to launch a lifeboat on the port side, when he got swept by a wave and the door burst behind him. He only remembered that until everything went black. He could’ve been hit in the head by the lifeboat, possibly getting a minor skull fracture. He found himself in the hospital when he woke up.
ae027a15d8d801f937009c11fcf71cd71287cbb5
Category:WIP
14
164
364
2023-10-02T12:50:02Z
Reverie
2
Created page with "Pages that are a work in progress, or not completed belongs here."
wikitext
text/x-wiki
Pages that are a work in progress, or not completed belongs here.
dddc750290f892b07676e5046b7ec23338dfea44
TSS Sarnia (1952)
0
165
365
2023-10-02T12:53:31Z
AguyInAsuit
5
Created page with "TSS Sarnia was an ocean liner built between 1949 and 1952 by Cammell Laird in Birkenhead for the Transoceanic Maritime Company to be operated by Transoceanic Line. She was launched on 23 November 1951 and christened by Queen Elizabeth the second. She was the second of the Caesarea-class ships. The new liner was assessed at 32,782 gross registered tons, with an overall length of 251 meters with a beam of 31 meters and had an exterior design nearly identical to her siste..."
wikitext
text/x-wiki
TSS Sarnia was an ocean liner built between 1949 and 1952 by Cammell Laird in Birkenhead for the Transoceanic Maritime Company to be operated by Transoceanic Line. She was launched on 23 November 1951 and christened by Queen Elizabeth the second. She was the second of the Caesarea-class ships.
The new liner was assessed at 32,782 gross registered tons, with an overall length of 251 meters with a beam of 31 meters and had an exterior design nearly identical to her sister ships, Caesarea and Riduna.
The vessel was powered by four sets of Parsons single reduction-geared steam turbines giving 53,000 shaft horsepower and driving quadruple propellers. Her service speed was 25 knots, with a maximum speed of 27 knots.
Background
On 9 January 1947, a new liner for the Transoceanic Line was laid down, and was to be named Caesarea. She was 257m long, the fifth longest in the line since.
On 6 February 1948, a meeting in the Transoceanic Line stated that Caesarea cannot be a solo liner, and that she needed a running mate. It was decided to build Sarnia as a sister ship for Caesarea. However, Sarnia was designed way more elegant, luxurious, and to be faster than her sister ship. Sarnia needed to be smaller than the Caesarea offering less rooms but more luxury. She was shorter in length by 6 meters, and less wide by 2 meters.The owners looked at Sarnia as a very successful ship, she managed to be a successful running mate by the side of Caesarea.
Design and construction (1949-1952)
Sarnia and her sister ships were designed by Eugene Campbell, who also helped design Belle of London, a famous ship of the same company but under a different line.
On 30 May 1949, Cammell Laird laid Sarnia’s keel on slipway number 807 in its Birkenhead shipyard. She was launched on 23 November 1951. She started 3 days of sea trials in the Severn Estuary, on 6 June 1952 and was completed on 12 June 1952. By the time of her completion, she was the sixth largest ship in the Transoceanic Line fleet, behind greater ships of the same line like Oceania and Mariana.
The ship was named Sarnia to honor the previous record breaking ocean liner from 1913 which had been scrapped in 1938. The ship has been designed for Liverpool to New York city service, but she can be easily converted to cruising, especially world cruises.
Career (1952-1958)
Sarnia’s career was fairly successful, even more successful than her larger sister, Caesarea. She quickly gained the attention of the press when her maiden voyage was announced, and it was believed that more than thousands of people came to her maiden voyage to see the ship leave Liverpool. She even gained more trust from the press when she completed several successful voyages along with her sister, she took the headlight from any other ships at the time, even more thousands would board her, watch her depart the ports of Liverpool and New York. In 1954, she would be refitted with the recent experimental technology, radars, after having recently collided with the oil tanker, Duke Wellington. She would go on to have a successful career despite the collision, until her sinking in 1958.
Incidents
On 27 December 1953, while heading to Cherbourg, she collided with the oil tanker Duke Wellington, due to human error and it being very foggy. She and Duke Wellington suffered minor damages, and Sarnia returned to Plymouth to be repaired and also refitted.
Sinking
On the fateful night on 1 October 1958, Sarnia was sailing from Cherbourg to Plymouth when her captain, Cape Dobber decided to do a showoff to a nearby beach before heading to the port. During the showoff a radar malfunction led to the radar not properly working therefore failing to detect nearby rocks. As Sarnia’s captain was doing his showoff, he failed to see a pile of rocks, being distracted by the crowd nearby watching Sarnia pass by.
Sarnia was getting too close to the shore on the starboard side causing the bow to collide with
rocks, creating several continuous holes along her hull. The holes expanded continuously, until it reached her starboard stabilizer, therefore bending it, causing the ship to tilt 5 degrees to the starboard.
Captain Dobber decided to not stay in place and evacuate passengers but chose to continue his showoff which would not only allow the rocks to collide with the propellers bending the blade of the very right propellor causing it to malfunction, but her hanging letters on top of the officers quarters would also collapse due to the sudden vibration and tilt, falling on a lifeboat breaking it in two and also crushing an officer who would later drown due to the chaos between the masses of passengers.
Shortly after the collision, even though the ship's power would start to faint as her boilers were giving up no steam therefore decreasing the pressure in the electricity generators, the passengers thought that everything was under control until 2 minutes later the ship would then take a heavy list to the starboard side almost being a 45 degree angle. With several gaps, a bended stabilizer that could not function, the ship could no longer handle the angle and therefore capsizing only 9 minutes after collision, this would lead to only 1 Lifeboat being launched, the other lifeboats were still getting ready and set up when the sudden capsizing occurred, the ship would lay in the water upside down powerless when one of the crew, Samuel would do a heroic action that put his life at risk, the brave crew member decided to dive to the nearest gangway door which was held open as to help in filling the lifeboats that never got lowered, he got hang of a room that had an air pocket, he managed to rescue almost quarter of the passengers who were trapped inside losing hope, that was lucky enough to stay in air pockets.
Aftermath of sinking
Immediate aftermath
Sarnia’s sistership, Caesarea, quickly arrived to the scene as the first, just after half an hour, instinctively as a running mate. However, by the time that Caesarea arrived, most people had swum to the shores of Plymouth.
Dolly Kristensen, one of the passengers onboard Caesarea, said that there was debris from Sarnia everywhere. Immediately Caesarea began to rescue the lifeboat from Sarnia, some passengers were reported to have feared to enter aboard Caesarea, because it reminded them of the sinking ship they had just survived from. Boarding Caesarea the traumatized passengers kept worrying about their relatives and families, it was stated in some recordings that even some fainted from the stress, however the medical staff onboard Caesarea knew how to deal with this, the crew started to calm passengers down, the maids were on continuous routes getting tea, coffee and water to help the in need passengers.
The second to the scene was the tender Dawnrise. It picked up remaining drowning passengers in the water, most holding onto the deckchairs of Sarnia.
Caesarea’s arrival at Plymouth created a frenzy of press interest. It took four days to complete the list of casualties; which resulted in 426 deaths and 292 survivors.
Transoceanic Line chartered the cable ship, CS Vancouver to pick up the floating remains in the scene.
Wreck
Just 4 days after Sarnia had sunk, it was determined that she had hit the seabed before going completely underwater, explaining why her stern was in a bad state. On the wreck, divers found many passengers stuck in elevators, attempting to get out to the upper decks.
Since its initial discovery, the wreck of Sarnia has been revisited on numerous occasions by explorers, tourists and salvagers, who have recovered thousands of items from the debris field for conservation and public display. The ship's condition has deteriorated significantly over the years, particularly from accidental damage by submersibles.
Submersibles that visited the ship did recognizable damage to the ship as some of them would land on the weak hull plating, floor or riveting, some even causing the plates to break or fall in. Some other submersibles were rather respecting the wreckage as a cemetery for those who died, only leaving a memorial sign or a word of respect to the dead people.
A famous destination for divers is the two deck dining room on the wrecked Sarnia. Dishes and plates, marked “807”, Sarnia’s hull number, are often retrieved to be kept as a souvenir or display.
On 8 November 1958, Sarnia was declared a grave site, thus retrieving bodies is not allowed.
CREDITS :
Article writing : Belarus_guy123 and barkiro2010
History writing : barkiro2010
Fictional scenery: Belarus_guy123
Fictional dates and locations : Belarus_guy123
Creator of Sarnia: barkiro2010
e3e2d1f87843f553aea2064c08b5a37b469f1fe6
366
365
2023-10-02T13:09:08Z
Reverie
2
EVERYTHING
wikitext
text/x-wiki
'''TSS ''Sarnia''''' was an ocean liner built between 1949 and 1952 by [[W:Cammell Laird|Cammell Laird]] in [[W:Birkenhead|Birkenhead]] for the [[Transoceanic Maritime Company]] to be operated by [[Transoceanic Line]]. She was launched on 23 November 1951 and christened by [[W:Queen Elizabeth the second|Queen Elizabeth the second]]. She was the second of the ''Caesarea''-class ships.
The new liner was assessed at 32,782 gross registered tons, with an overall length of 251 meters with a beam of 31 meters and had an exterior design nearly identical to her sister ships, ''[[TSS Caesarea (1951)|Caesarea]]'' and ''[[TSS Riduna (1953)|Riduna]]''.
The vessel was powered by four sets of [[W:Turbine engines|Parsons single reduction-geared steam turbines]] giving 53,000 shaft horsepower and driving quadruple propellers. Her service speed was 25 knots, with a maximum speed of 27 knots.
== Background ==
On 9 January 1947, a new liner for the Transoceanic Line was laid down, and was to be named ''Caesarea''. She was 257m long, the fifth longest in the line since.
On 6 February 1948, a meeting in the Transoceanic Line stated that ''Caesarea'' cannot be a solo liner, and that she needed a running mate. It was decided to build Sarnia as a sister ship for ''Caesarea''. However, ''Sarnia'' was designed way more elegant, luxurious, and to be faster than her sister ship. ''Sarnia'' needed to be smaller than the <u>''Caesarea''</u> offering less rooms but more luxury. She was shorter in length by 6 meters, and less wide by 2 meters.
The owners looked at ''Sarnia'' as a very successful ship, she managed to be a successful running mate by the side of ''Caesarea''.
== Design and construction (1949-1952) ==
''Sarnia'' and her sister ships were designed by [[Eugene Campbell]], who also helped design ''Belle of London'', a famous ship of the same company but under [[Belle Line|a different line]].
On 30 May 1949, Cammell Laird laid ''Sarnia''<nowiki/>'s keel on slipway number 807 in its Birkenhead shipyard. She was launched on 23 November 1951. She started 3 days of sea trials in the [[W:Severn Estuary|Severn Estuary]], on 6 June 1952 and was completed on 12 June 1952. By the time of her completion, she was the sixth largest ship in the Transoceanic Line fleet, behind greater ships of the same line like ''[[RMS Oceania (1932)|Oceania]]'' and ''[[QSMV Mariana (1939)|Mariana]]''.
The ship was named ''Sarnia'' to honor the previous record breaking ocean liner from 1913 which had been scrapped in 1938. The ship has been designed for [[W:Liverpool|Liverpool]] to [[W:New York City|New York City]] service, but she can be easily converted to cruising, especially world cruises.
== Career (1952-1958) ==
''Sarnia''<nowiki/>'s career was fairly successful, even more successful than her larger sister, ''Caesarea''. She quickly gained the attention of the press when her maiden voyage was announced, and it was believed that more than thousands of people came to her maiden voyage to see the ship leave Liverpool. She even gained more trust from the press when she completed several successful voyages along with her sister, she took the headlight from any other ships at the time, even more thousands would board her, watch her depart the ports of Liverpool and New York. In 1954, she would be refitted with the recent experimental technology, [[W:Radars|radars]], after having recently collided with the oil tanker, [[MT Duke Wellington (1949)|''Duke Wellington'']]. She would go on to have a successful career despite the collision, until her sinking in 1958.
== Incidents ==
On 27 December 1953, while heading to [[W:Cherbourg|Cherbourg]], she collided with the oil tanker ''Duke Wellington'', due to human error and it being very foggy. She and ''Duke Wellington'' suffered minor damages, and Sarnia returned to Plymouth to be repaired and also refitted.
== Sinking ==
On the fateful night on 1 October 1958, ''Sarnia'' was sailing from Cherbourg to [[W:Plymouth|Plymouth]] when her captain, [[Cape Dobber]] decided to do a showoff to a nearby beach before heading to the port. During the showoff a radar malfunction led to the radar not properly working therefore failing to detect nearby rocks. As ''Sarnia''’s captain was doing his showoff, he failed to see a pile of rocks, being distracted by the crowd nearby watching ''Sarnia'' pass by.
''Sarnia'' was getting too close to the shore on the starboard side causing the bow to collide with rocks, creating several continuous holes along her hull. The holes expanded continuously, until it reached her starboard stabilizer, therefore bending it, causing the ship to tilt 5 degrees to the starboard.
Captain Dobber decided to not stay in place and evacuate passengers but chose to continue his showoff which would not only allow the rocks to collide with the propellers bending the blade of the very right propellor causing it to malfunction, but her hanging letters on top of the officers quarters would also collapse due to the sudden vibration and tilt, falling on a lifeboat breaking it in two and also crushing an officer who would later drown due to the chaos between the masses of passengers.
Shortly after the collision, even though the ship's power would start to faint as her boilers were giving up no steam therefore decreasing the pressure in the electricity generators, the passengers thought that everything was under control until 2 minutes later the ship would then take a heavy list to the starboard side almost being a 45 degree angle. With several gaps, a bended stabilizer that could not function, the ship could no longer handle the angle and therefore capsizing only 9 minutes after collision, this would lead to only 1 lifeboat being launched, the other lifeboats were still getting ready and set up.
When the sudden capsizing occurred, the ship would lay in the water upside down powerless when one of the crew, Officer Samuel Handerson, would do a heroic action that put his life at risk, the brave crew member decided to dive to the nearest gangway door which was held open as to help in filling the lifeboats that never got lowered, he got hang of a room that had an air pocket, he managed to rescue almost quarter of the passengers who were trapped inside losing hope, that was lucky enough to stay in air pockets.
== Aftermath of sinking ==
=== Immediate aftermath ===
''Sarnia''’s sistership, ''Caesarea'', quickly arrived to the scene as the first, just after half an hour, instinctively as a running mate. However, by the time that ''Caesarea'' arrived, most people had swum to the shores of Plymouth.
Dolly Kristensen, one of the passengers onboard ''Caesarea'', said that there was debris from ''Sarnia'' everywhere. Immediately ''Caesarea'' began to rescue the lifeboat from ''Sarnia'', some passengers were reported to have feared to enter aboard ''Caesarea'', because it reminded them of the sinking ship they had just survived from. Boarding ''Caesarea'' the traumatized passengers kept worrying about their relatives and families, it was stated in some recordings that even some fainted from the stress, however the medical staff onboard ''Caesarea'' knew how to deal with this, the crew started to calm passengers down, the maids were on continuous routes getting tea, coffee and water to help the in need passengers.
The second to the scene was the tender [[SS Dawnrise (tender)|Dawnrise]]. It picked up remaining drowning passengers in the water, most holding onto the deckchairs of ''Sarnia''.
''Caesarea''’s arrival at Plymouth created a frenzy of press interest. It took four days to complete the list of casualties; which resulted in 426 deaths and 292 survivors.
Transoceanic Line chartered the cable ship, [[CS Vancouver (cable ship)|CS ''Vancouver'']] to pick up the floating remains in the scene.
== Wreck ==
Just 4 days after ''Sarnia'' had sunk, it was determined that she had hit the seabed before going completely underwater, explaining why her stern was in a bad state. On the wreck, divers found many passengers stuck in elevators, attempting to get out to the upper decks.
Since its initial discovery, the wreck of ''Sarnia'' has been revisited on numerous occasions by explorers, tourists and salvagers, who have recovered thousands of items from the debris field for conservation and public display. The ship's condition has deteriorated significantly over the years, particularly from accidental damage by submersibles.
Submersibles that visited the ship did recognizable damage to the ship as some of them would land on the weak hull plating, floor or riveting, some even causing the plates to break or fall in. Some other submersibles were rather respecting the wreckage as a cemetery for those who died, only leaving a memorial sign or a word of respect to the dead people.
A famous destination for divers is the two deck dining room on the wrecked ''Sarnia''. Dishes and plates, marked “807”, ''Sarnia''’s hull number, are often retrieved to be kept as a souvenir or display.
On 8 November 1958, the wreck of ''Sarnia'' was declared a grave site, thus retrieving bodies is not allowed.
37b0f0b63cfa0386a07010086c08db3db16a6131
371
366
2023-10-02T13:18:52Z
Reverie
2
wikitext
text/x-wiki
'''TSS ''Sarnia''''' was an ocean liner built between 1949 and 1952 by [[W:Cammell Laird|Cammell Laird]] in [[W:Birkenhead|Birkenhead]] for the [[Transoceanic Maritime Company]] to be operated by [[Transoceanic Line]]. She was launched on 23 November 1951 and christened by [[W:Queen Elizabeth the second|Queen Elizabeth the second]]. She was the second of the ''Caesarea''-class ships.
{{DISPLAYTITLE:TSS ''Sarnia'' (1952)}}
The new liner was assessed at 32,782 gross registered tons, with an overall length of 251 meters with a beam of 31 meters and had an exterior design nearly identical to her sister ships, ''[[TSS Caesarea (1951)|Caesarea]]'' and ''[[TSS Riduna (1953)|Riduna]]''.
The vessel was powered by four sets of [[W:Turbine engines|Parsons single reduction-geared steam turbines]] giving 53,000 shaft horsepower and driving quadruple propellers. Her service speed was 25 knots, with a maximum speed of 27 knots.
== Background ==
On 9 January 1947, a new liner for the Transoceanic Line was laid down, and was to be named ''Caesarea''. She was 257m long, the fifth longest in the line since.
On 6 February 1948, a meeting in the Transoceanic Line stated that ''Caesarea'' cannot be a solo liner, and that she needed a running mate. It was decided to build Sarnia as a sister ship for ''Caesarea''. However, ''Sarnia'' was designed way more elegant, luxurious, and to be faster than her sister ship. ''Sarnia'' needed to be smaller than the ''Caesarea'' offering less rooms but more luxury. She was shorter in length by 6 meters, and less wide by 2 meters.
The owners looked at ''Sarnia'' as a very successful ship, she managed to be a successful running mate by the side of ''Caesarea''.
== Design and construction (1949-1952) ==
''Sarnia'' and her sister ships were designed by [[Eugene Campbell]], who also helped design ''Belle of London'', a famous ship of the same company but under [[Belle Line|a different line]].
On 30 May 1949, Cammell Laird laid ''Sarnia''<nowiki/>'s keel on slipway number 807 in its Birkenhead shipyard. She was launched on 23 November 1951. She started 3 days of sea trials in the [[W:Severn Estuary|Severn Estuary]], on 6 June 1952 and was completed on 12 June 1952. By the time of her completion, she was the sixth largest ship in the Transoceanic Line fleet, behind greater ships of the same line like ''[[RMS Oceania (1932)|Oceania]]'' and ''[[QSMV Mariana (1939)|Mariana]]''.
The ship was named ''Sarnia'' to honor the previous record breaking ocean liner from 1913 which had been scrapped in 1938. The ship has been designed for [[W:Liverpool|Liverpool]] to [[W:New York City|New York City]] service, but she can be easily converted to cruising, especially world cruises.
== Career (1952-1958) ==
''Sarnia''<nowiki/>'s career was fairly successful, even more successful than her larger sister, ''Caesarea''. She quickly gained the attention of the press when her maiden voyage was announced, and it was believed that more than thousands of people came to her maiden voyage to see the ship leave Liverpool. She even gained more trust from the press when she completed several successful voyages along with her sister, she took the headlight from any other ships at the time, even more thousands would board her, watch her depart the ports of Liverpool and New York. In 1954, she would be refitted with the recent experimental technology, [[W:Radars|radars]], after having recently collided with the oil tanker, [[MT Duke Wellington (1949)|''Duke Wellington'']]. She would go on to have a successful career despite the collision, until her sinking in 1958.
== Incidents ==
On 27 December 1953, while heading to [[W:Cherbourg|Cherbourg]], she collided with the oil tanker ''Duke Wellington'', due to human error and it being very foggy. She and ''Duke Wellington'' suffered minor damages, and Sarnia returned to Plymouth to be repaired and also refitted.
== Sinking ==
On the fateful night on 1 October 1958, ''Sarnia'' was sailing from Cherbourg to [[W:Plymouth|Plymouth]] when her captain, [[Cape Dobber]] decided to do a showoff to a nearby beach before heading to the port. During the showoff a radar malfunction led to the radar not properly working therefore failing to detect nearby rocks. As ''Sarnia''’s captain was doing his showoff, he failed to see a pile of rocks, being distracted by the crowd nearby watching ''Sarnia'' pass by.
''Sarnia'' was getting too close to the shore on the starboard side causing the bow to collide with rocks, creating several continuous holes along her hull. The holes expanded continuously, until it reached her starboard stabilizer, therefore bending it, causing the ship to tilt 5 degrees to the starboard.
Captain Dobber decided to not stay in place and evacuate passengers but chose to continue his showoff which would not only allow the rocks to collide with the propellers bending the blade of the very right propellor causing it to malfunction, but her hanging letters on top of the officers quarters would also collapse due to the sudden vibration and tilt, falling on a lifeboat breaking it in two and also crushing an officer who would later drown due to the chaos between the masses of passengers.
Shortly after the collision, even though the ship's power would start to faint as her boilers were giving up no steam therefore decreasing the pressure in the electricity generators, the passengers thought that everything was under control until 2 minutes later the ship would then take a heavy list to the starboard side almost being a 45 degree angle. With several gaps, a bended stabilizer that could not function, the ship could no longer handle the angle and therefore capsizing only 9 minutes after collision, this would lead to only 1 lifeboat being launched, the other lifeboats were still getting ready and set up.
When the sudden capsizing occurred, the ship would lay in the water upside down powerless when one of the crew, Officer Samuel Handerson, would do a heroic action that put his life at risk, the brave crew member decided to dive to the nearest gangway door which was held open as to help in filling the lifeboats that never got lowered, he got hang of a room that had an air pocket, he managed to rescue almost quarter of the passengers who were trapped inside losing hope, that was lucky enough to stay in air pockets.
== Aftermath of sinking ==
=== Immediate aftermath ===
''Sarnia''’s sistership, ''Caesarea'', quickly arrived to the scene as the first, just after half an hour, instinctively as a running mate. However, by the time that ''Caesarea'' arrived, most people had swum to the shores of Plymouth.
Dolly Kristensen, one of the passengers onboard ''Caesarea'', said that there was debris from ''Sarnia'' everywhere. Immediately ''Caesarea'' began to rescue the lifeboat from ''Sarnia'', some passengers were reported to have feared to enter aboard ''Caesarea'', because it reminded them of the sinking ship they had just survived from. Boarding ''Caesarea'' the traumatized passengers kept worrying about their relatives and families, it was stated in some recordings that even some fainted from the stress, however the medical staff onboard ''Caesarea'' knew how to deal with this, the crew started to calm passengers down, the maids were on continuous routes getting tea, coffee and water to help the in need passengers.
The second to the scene was the tender [[SS Dawnrise (tender)|Dawnrise]]. It picked up remaining drowning passengers in the water, most holding onto the deckchairs of ''Sarnia''.
''Caesarea''’s arrival at Plymouth created a frenzy of press interest. It took four days to complete the list of casualties; which resulted in 426 deaths and 292 survivors.
Transoceanic Line chartered the cable ship, [[CS Vancouver (cable ship)|CS ''Vancouver'']] to pick up the floating remains in the scene.
== Wreck ==
Just 4 days after ''Sarnia'' had sunk, it was determined that she had hit the seabed before going completely underwater, explaining why her stern was in a bad state. On the wreck, divers found many passengers stuck in elevators, attempting to get out to the upper decks.
Since its initial discovery, the wreck of ''Sarnia'' has been revisited on numerous occasions by explorers, tourists and salvagers, who have recovered thousands of items from the debris field for conservation and public display. The ship's condition has deteriorated significantly over the years, particularly from accidental damage by submersibles.
Submersibles that visited the ship did recognizable damage to the ship as some of them would land on the weak hull plating, floor or riveting, some even causing the plates to break or fall in. Some other submersibles were rather respecting the wreckage as a cemetery for those who died, only leaving a memorial sign or a word of respect to the dead people.
A famous destination for divers is the two deck dining room on the wrecked ''Sarnia''. Dishes and plates, marked “807”, ''Sarnia''’s hull number, are often retrieved to be kept as a souvenir or display.
On 8 November 1958, the wreck of ''Sarnia'' was declared a grave site, thus retrieving bodies is not allowed.
dc6ba95d01289e74e03c5fdc675d87ca74f61442
372
371
2023-10-02T13:26:53Z
Reverie
2
wikitext
text/x-wiki
'''TSS ''Sarnia''''' was an ocean liner built between 1949 and 1952 by [[W:Cammell Laird|Cammell Laird]] in [[W:Birkenhead|Birkenhead]] for the [[Transoceanic Maritime Company]] to be operated by [[Transoceanic Line]]. She was launched on 23 November 1951 and christened by [[W:Queen Elizabeth the second|Queen Elizabeth the second]]. She was the second of the ''Caesarea''-class ships.
{{DISPLAYTITLE:TSS ''Sarnia'' (1952)}}
The new liner was assessed at 32,782 gross registered tons, with an overall length of 251 meters with a beam of 31 meters and had an exterior design nearly identical to her sister ships, ''[[TSS Caesarea (1951)|Caesarea]]'' and ''[[TSS Riduna (1953)|Riduna]]''.
The vessel was powered by four sets of [[W:Turbine engines|Parsons single reduction-geared steam turbines]] giving 53,000 shaft horsepower and driving quadruple propellers. Her service speed was 25 knots, with a maximum speed of 27 knots.
== Background ==
On 9 January 1947, a new liner for the Transoceanic Line was laid down, and was to be named ''Caesarea''. She was 257m long, the fifth longest in the line since.
On 6 February 1948, a meeting in the Transoceanic Line stated that ''Caesarea'' cannot be a solo liner, and that she needed a running mate. It was decided to build Sarnia as a sister ship for ''Caesarea''. However, ''Sarnia'' was designed way more elegant, luxurious, and to be faster than her sister ship. ''Sarnia'' needed to be smaller than the ''Caesarea'' offering less rooms but more luxury. She was shorter in length by 6 meters, and less wide by 2 meters.
The owners looked at ''Sarnia'' as a very successful ship, she managed to be a successful running mate by the side of ''Caesarea''.
== Design and construction (1949-1952) ==
''Sarnia'' and her sister ships were designed by [[Eugene Campbell]], who also helped design ''Belle of London'', a famous ship of the same company but under [[Belle Line|a different line]].
On 30 May 1949, Cammell Laird laid ''Sarnia''<nowiki/>'s keel on slipway number 807 in its Birkenhead shipyard. She was launched on 23 November 1951. She started 3 days of sea trials in the [[W:Severn Estuary|Severn Estuary]], on 6 June 1952 and was completed on 12 June 1952. By the time of her completion, she was the sixth largest ship in the Transoceanic Line fleet, behind greater ships of the same company like ''[[RMS Oceania (1932)|Oceania]]'' and ''[[QSMV Mariana (1939)|Mariana]]''.
The ship was named ''Sarnia'' to honor the previous record breaking ocean liner from 1913 which had been scrapped in 1938. The ship has been designed for [[W:Liverpool|Liverpool]] to [[W:New York City|New York City]] service, but she can be easily converted to cruising, especially world cruises.
== Career (1952-1958) ==
''Sarnia''<nowiki/>'s career was fairly successful, even more successful than her larger sister, ''Caesarea''. She quickly gained the attention of the press when her maiden voyage was announced, and it was believed that more than thousands of people came to her maiden voyage to see the ship leave Liverpool. She even gained more trust from the press when she completed several successful voyages along with her sister, she took the headlight from any other ships at the time, even more thousands would board her, watch her depart the ports of Liverpool and New York. In 1954, she would be refitted with the recent experimental technology, [[W:Radars|radars]], after having recently collided with the oil tanker, [[MT Duke Wellington (1949)|''Duke Wellington'']]. She would go on to have a successful career despite the collision, until her sinking in 1958.
== Incidents ==
On 27 December 1953, while heading to [[W:Cherbourg|Cherbourg]], she collided with the oil tanker ''Duke Wellington'', due to human error and it being very foggy. She and ''Duke Wellington'' suffered minor damages, and Sarnia returned to Plymouth to be repaired and also refitted.
== Sinking ==
On the fateful night on 1 October 1958, ''Sarnia'' was sailing from Cherbourg to [[W:Plymouth|Plymouth]] when her captain, [[Cape Dobber]] decided to do a showoff to a nearby beach before heading to the port. During the showoff a radar malfunction led to the radar not properly working therefore failing to detect nearby rocks. As ''Sarnia''’s captain was doing his showoff, he failed to see a pile of rocks, being distracted by the crowd nearby watching ''Sarnia'' pass by.
''Sarnia'' was getting too close to the shore on the starboard side causing the bow to collide with rocks, creating several continuous holes along her hull. The holes expanded continuously, until it reached her starboard stabilizer, therefore bending it, causing the ship to tilt 5 degrees to the starboard.
Captain Dobber decided to not stay in place and evacuate passengers but chose to continue his showoff which would not only allow the rocks to collide with the propellers bending the blade of the very right propellor causing it to malfunction, but her hanging letters on top of the officers quarters would also collapse due to the sudden vibration and tilt, falling on a lifeboat breaking it in two and also crushing an officer who would later drown due to the chaos between the masses of passengers.
Shortly after the collision, even though the ship's power would start to faint as her boilers were giving up no steam therefore decreasing the pressure in the electricity generators, the passengers thought that everything was under control until 2 minutes later the ship would then take a heavy list to the starboard side almost being a 45 degree angle. With several gaps, a bended stabilizer that could not function, the ship could no longer handle the angle and therefore capsizing only 9 minutes after collision, this would lead to only 1 lifeboat being launched, the other lifeboats were still getting ready and set up.
When the sudden capsizing occurred, the ship would lay in the water upside down powerless when one of the crew, Officer Samuel Handerson, would do a heroic action that put his life at risk, the brave crew member decided to dive to the nearest gangway door which was held open as to help in filling the lifeboats that never got lowered, he got hang of a room that had an air pocket, he managed to rescue almost quarter of the passengers who were trapped inside losing hope, that was lucky enough to stay in air pockets.
== Aftermath of sinking ==
=== Immediate aftermath ===
''Sarnia''’s sistership, ''Caesarea'', quickly arrived to the scene as the first, just after half an hour, instinctively as a running mate. However, by the time that ''Caesarea'' arrived, most people had swum to the shores of Plymouth.
Dolly Kristensen, one of the passengers onboard ''Caesarea'', said that there was debris from ''Sarnia'' everywhere. Immediately ''Caesarea'' began to rescue the lifeboat from ''Sarnia'', some passengers were reported to have feared to enter aboard ''Caesarea'', because it reminded them of the sinking ship they had just survived from. Boarding ''Caesarea'' the traumatized passengers kept worrying about their relatives and families, it was stated in some recordings that even some fainted from the stress, however the medical staff onboard ''Caesarea'' knew how to deal with this, the crew started to calm passengers down, the maids were on continuous routes getting tea, coffee and water to help the in need passengers.
The second to the scene was the tender [[SS Dawnrise (tender)|Dawnrise]]. It picked up remaining drowning passengers in the water, most holding onto the deckchairs of ''Sarnia''.
''Caesarea''’s arrival at Plymouth created a frenzy of press interest. It took four days to complete the list of casualties; which resulted in 426 deaths and 292 survivors.
Transoceanic Line chartered the cable ship, [[CS Vancouver (cable ship)|CS ''Vancouver'']] to pick up the floating remains in the scene.
== Wreck ==
Just 4 days after ''Sarnia'' had sunk, it was determined that she had hit the seabed before going completely underwater, explaining why her stern was in a bad state. On the wreck, divers found many passengers stuck in elevators, attempting to get out to the upper decks.
Since its initial discovery, the wreck of ''Sarnia'' has been revisited on numerous occasions by explorers, tourists and salvagers, who have recovered thousands of items from the debris field for conservation and public display. The ship's condition has deteriorated significantly over the years, particularly from accidental damage by submersibles.
Submersibles that visited the ship did recognizable damage to the ship as some of them would land on the weak hull plating, floor or riveting, some even causing the plates to break or fall in. Some other submersibles were rather respecting the wreckage as a cemetery for those who died, only leaving a memorial sign or a word of respect to the dead people.
A famous destination for divers is the two deck dining room on the wrecked ''Sarnia''. Dishes and plates, marked “807”, ''Sarnia''’s hull number, are often retrieved to be kept as a souvenir or display.
On 8 November 1958, the wreck of ''Sarnia'' was declared a grave site, thus retrieving bodies is not allowed.
d0065888384903e7adebf744682a7eb41c88a044
RMS Belle of England (1937)
0
151
367
346
2023-10-02T13:11:04Z
Reverie
2
wikitext
text/x-wiki
{{WIP}}
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! colspan="2" | [[File:{{{img|Belle of England in Jersey (1939).jpeg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Belle of England'' at [[w:Jersey|Jersey]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Transoceanic Maritime Company]]
|-
! style="background: #f8f9fb;"| Operator
| [[Belle Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[Belle of Scotland]]'' and running mate ''[[Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
27ac7b5281a5cb72e80ce4c704fbaed60de490d6
368
367
2023-10-02T13:12:28Z
Reverie
2
wikitext
text/x-wiki
{{WIP}}
'''RMS ''Belle of England''''' was an [[W:Ocean liner|ocean liner]] built between 1935 and 1938 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 4 September 1937, she became the largest ship in the Belle fleet at the time and was the second of three Belle ships named ''Belle of England'' in the Belle fleet.
{| class="wikitable"
! colspan="2" | [[File:{{{img|Belle of England in Jersey (1939).jpeg}}}|300px]]
|-
| colspan="2" style="text-align: center" | <small>{{{capt|''Belle of England'' at [[w:Jersey|Jersey]]}}}</small>
|-
! style="background: #CECEF2;" colspan="2"| {{{subj|History}}}
|-
! style="background: #bfbfe3;" colspan="2"| {{{subj|[[w:United Kingdom|United Kingdom]]}}}
|-
! colspan="2" {{#if: {{{img|}}}||style="display: none"}} |
|- {{#if: {{{img|}}}||style="display: none"}}
|-
! style="background: #f8f9fb;"| Owner
| [[Transoceanic Maritime Company]]
|-
! style="background: #f8f9fb;"| Operator
| [[Belle Line]]
|-
! style="background: #f8f9fb;"| Port of registry
| {{{registry|[[w:Liverpool|Liverpool]], England}}}
|}
She, along with her sistership ''[[RMS Belle of Scotland (1936)|Belle of Scotland]]'' and running mate ''[[RMS Caledonia (1934)|Caledonia]]'' served the [[W:London|London]]-[[W:New York|New York]] route which was a usual route of the Belle Line.
The ''Belle of England'' was considered the most luxurious ship at her time that served for the Belle fleet. She went through a big refit in 1953, changing from her traditional looks to a modern cruise ship, extending her career.
In 1961, she was sold to [[Continental Cruises]] and was renamed '''''Continent'''''. During her services for Continental Cruises she ran Caribbean cruises; going regularly through the [[W:West Indies|West Indies]] and [[W:Panama|Panama]]. In 1983, she was sold for scrap after being retired. Plans to turn her into a [[W:hotelship|hotel ship]] were unsuccessful.
== Background ==
After losing their pride flagship, ''[[Belle of London]]'', Belle Line started to focus on comfort and luxury rather than breaking records. A recent plan for a superliner was canceled earlier from the [[W:Great depression|great depression]], and like many other lines, they had to start scrapping ships as upkeeping all of the ships in the Belle fleet would've been too expensive.
== Design and construction ==
''Belle of England'' and ''Belle of Scotland'' were both designed by Belle naval architect [[Greg Collins]], who also designed the notorious ''Belle of London''. He was tasked with emphasizing comfort, and reducing as much rocking in rough weather as possible.
The name ''Belle of England'' and ''Belle of Scotland'' was given to the sisterships to honor Belle Line’s previous duo under the same name from 1913.
On 24 April 1935 Harland and Wolf laid Belle of England’s keel on slip number one in its Belfast yard. She was launched and christened on 4 September 1937, and began sea trials on 27 May 1938 at [[W:Thames Estuary|Thames Estuary]] where she tested 25.3 knots, and was completed on 24 June 1938. ''Belle of England'' had two propellers installed, each driven by a set of Parsons single reduction-geared steam turbines giving 41,000 shaft horsepower (~30,150 kW).
''Belle of England'' was built as a cabin liner, but she can easily be converted to cruises like world cruising. She was built for a capacity of 1,290 passengers; 326 in First Class, 429 Second Class, and 535 in Tourist Class. Cabins in second class and tourist class are very similar, hinting to be converted to two class cruises. She had a gymnasium, an indoor swimming pool, and her first class dining saloon was in [[W:Louis XIV furniture|Louis XIV style]]. She was equipped with 18 lifeboats, 2 motor boats, and 4 backup boats.
''Belle of England'' had two funnels, only her aft funnel was a real exhaust funnel, her fore funnel was a dummy used for containing water tanks.
''Belle of England'' was painted in the Belle livery; Black hull with a white line, yellow ventilators, red boot-topping, and golden funnels. However, after 1939 and onwards, she was painted in a new unique livery; light [[w: Shades of rose|oyster pink]] hull with a blue line, yellow ventilators, green boot-topping and golden funnels. Both ''Belle of England'' and ''Belle of Scotland'' kept this livery onwards.
{{DISPLAYTITLE:RMS ''Belle of England'' (1937)}}
b55f6cfbfcb16d7d19d6c2c31f2fdb68be2f0894
RMS Belle of Scotland (1936)
0
166
369
2023-10-02T13:15:36Z
Reverie
2
Created page with "{{WIP}} {{Placeholder}} '''RMS ''Belle of Scotland''''' was an [[W:Ocean liner|ocean liner]] built between 1934 and 1937 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 7 March 1936, she became the largest ship in the Belle fleet for a short period of time before being surpassed by her sister, ''[[RMS Belle of England|Belle of England]]''. She was the first..."
wikitext
text/x-wiki
{{WIP}}
{{Placeholder}}
'''RMS ''Belle of Scotland''''' was an [[W:Ocean liner|ocean liner]] built between 1934 and 1937 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 7 March 1936, she became the largest ship in the Belle fleet for a short period of time before being surpassed by her sister, ''[[RMS Belle of England|Belle of England]]''. She was the first of two Belle ships named ''Belle of Scotland'' in the Belle fleet.
{{DISPLAYTITLE:RMS ''Belle of Scotland''}}
b304d984a24e9d1d1d3485aba9fe9693a7e7cb18
370
369
2023-10-02T13:16:07Z
Reverie
2
wikitext
text/x-wiki
{{WIP}}
{{Placeholder}}
'''RMS ''Belle of Scotland''''' was an [[W:Ocean liner|ocean liner]] built between 1934 and 1937 by [[W:Harland and Wolff|Harland and Wolff]] in [[W:Belfast|Belfast]], owned by the [[Transoceanic Maritime Company]] and operated by [[Belle Line]]. Launched on 7 March 1936, she became the largest ship in the Belle fleet for a short period of time before being surpassed by her sister, ''[[RMS Belle of England|Belle of England]]''. She was the first of two Belle ships named ''Belle of Scotland'' in the Belle fleet.
{{DISPLAYTITLE:RMS ''Belle of Scotland'' (1936)}}
520407a216055a46a33cdbed24ac6f7817c56769
QSMV Mariana (1939)
0
167
374
2023-10-02T13:55:59Z
Reverie
2
Created page with "{{WIP}} '''QSMV ''Mariana''''' was a British quadruple-screw ocean liner owned by the [[Transoceanic Maritime Company]] and operated by its subsidiary [[Belle Line]]. She was operated between [[W:Southampton|Southampton]] and [[W:Nassau|Nassau]] before and after the [[W:Second World War|Second World War]]. During the war she first served as an [[W:Armed merchant cruiser|armed merchant cruiser]] before converting into a [[W:Troop ship|troop ship]] in 1941. == Building =..."
wikitext
text/x-wiki
{{WIP}}
'''QSMV ''Mariana''''' was a British quadruple-screw ocean liner owned by the [[Transoceanic Maritime Company]] and operated by its subsidiary [[Belle Line]]. She was operated between [[W:Southampton|Southampton]] and [[W:Nassau|Nassau]] before and after the [[W:Second World War|Second World War]]. During the war she first served as an [[W:Armed merchant cruiser|armed merchant cruiser]] before converting into a [[W:Troop ship|troop ship]] in 1941.
== Building ==
Belle Line ordered ''Mariana'' to replace ''[[SS Belle of Nassau (1919)|Belle of Nassau]]'' which had been retired in January 1935. ''Mariana'' was the sistership of the older ''[[QSMV Marshall (1938)|Marshall]]'' which had just been launched in 17 March 1937.
[[W:Ferguson Marine|Ferguson Marine]] laid her keel down on 3 October 1936 at its shipyard in Glasgow. She was launched on 28 September 1938 and completed January 1939. She was 875.11 ft (267.8 m) long, had a beam of 84.3 ft (25.7 m), and a draught of 30.2 ft (9.2 m). When completed, she was as assesed over 43,427 GRT and 22,319 NRT. She had capacity for refrigerated cargo, and as built she had berths for 900 first class and 465 second class passengers. ''Mariana'', similarly to her sister ''Marshall'', consisted of two 15 [[W:Cylinder (engine)|cylinder]], [[W:Four stroke|four stroke]], [[W:Single- and double-acting cylinders|double acting]] [[W:Diesel engine|diesel engines]], designed by [[W:Burmeister & Wain|Burmeister & Wain]]. They were coupled to four propellers, and could produce 30,000 [[W:Brake horsepower|brake horsepower]]; these could propel the ship at a design service speed of 23 knots (42 km/h; 26 mph), although she often exceeded her limit, averaging 24.5 knots in service.
e2bfadd23a8af505ec9e4f4e1ae670be5e49c8f9
Parelian Line
0
168
376
2023-10-02T21:24:13Z
112.201.133.171
0
Added description for operator
wikitext
text/x-wiki
Parelian Line is a shipping line founded by Johnson M. Parelian in 1895.
cfb1fbc1c5fb6c866d5db0f1e958c35c54a444eb
379
376
2023-10-02T21:36:05Z
112.201.133.171
0
Added current ship info of operator
wikitext
text/x-wiki
Parelian Line is a shipping line founded by Johnson M. Parelian in 1895.
Their current ship in service is the ''Avelian'', a 314 meter long cruise ship that could accommodate roughly 4700 people onboard.
238bcb14b2123b2afb23b438e039965ec73bd629
383
379
2023-10-03T06:37:16Z
Reverie
2
wikitext
text/x-wiki
Parelian Line is a shipping line founded by Johnson M. Parelian in 1895.
Their current ship in service is the ''Avelian'', a 314 meter long cruise ship that could accommodate roughly 4700 people onboard.
{{WIP}}
8b37bb803a8adacd3f2d9ad4d434467b7fcfdb51
Maritime Industry Company
0
169
377
2023-10-02T21:29:11Z
112.201.133.171
0
Added owner info
wikitext
text/x-wiki
The Maritime Industry Company is a British shipping and cruiseline based at [[Glasgow]], England. Their upcoming ship is expected to arrive by ''2024''.
b3166cbb01831e3e5457e2432bbf70ce32191299
378
377
2023-10-02T21:30:01Z
112.201.133.171
0
Changed england to scotland
wikitext
text/x-wiki
The Maritime Industry Company is a British shipping and cruiseline based at [[Glasgow]], Scotland. Their upcoming ship is expected to arrive by ''2024''.
bd2e20bd83283b7c7f3f9fd67091edc43736e184
380
378
2023-10-03T06:28:17Z
Reverie
2
wikitext
text/x-wiki
The Maritime Industry Company is a British shipping and cruiseline based at [[Glasgow]], Scotland. Their upcoming ship is expected to arrive by ''2024''.
{{Placeholder}}
8ca9c9e83abd71170f443db7c7b68175958cb91f
382
380
2023-10-03T06:35:47Z
Reverie
2
wikitext
text/x-wiki
The Maritime Industry Company is a British shipping and cruiseline based at [[w:Glasgow|Glasgow]], Scotland. Their upcoming ship is expected to arrive by ''2024''.
{{Placeholder}}
e043bd010900de5744346de6794f53a282705487
Template:Placeholder
10
154
381
326
2023-10-03T06:34:51Z
Reverie
2
wikitext
text/x-wiki
{| style="border-spacing: 2px; border: 1px solid darkgray;"
|-
| This article is a placeholder. It is meant to fill an empty red link. Its completed article may be written soon.
'''''Please write a basic summary of the subject, do not just insert this template without context.'''''
<small>''[type <nowiki>{{placeholder}}</nowiki> to insert this in your article.]''</small>
|}
[[Category:Placeholder articles]]
[[Category:Stub]]
607ae8310886d6d4bfc49627bacb80b788bd41b4
Template:WIP
10
163
384
362
2023-10-03T06:38:26Z
Reverie
2
wikitext
text/x-wiki
{| class="wikitable"
|+ '''Work in progress!'''
|-
| ''This article is a W.I.P., which means that it is not completed yet. It may be completed soon in the future by its writters.'' '''''Please make sure to remove this template when the article is finished.'''''
<small>type <nowiki>{{WIP}}</nowiki> to insert this in your article.</small>
|}
[[Category:WIP]]
83f0408a0c5f0ca6550c69b3bd616d308e3c512a
385
384
2023-10-03T06:38:42Z
Reverie
2
wikitext
text/x-wiki
{| class="wikitable"
| '''Work in progress!'''
|-
| ''This article is a W.I.P., which means that it is not completed yet. It may be completed soon in the future by its writters.'' '''''Please make sure to remove this template when the article is finished.'''''
<small>type <nowiki>{{WIP}}</nowiki> to insert this in your article.</small>
|}
[[Category:WIP]]
6e7c91fee7c57b43e449d74f21fb02102037f7c0
Home
0
2
386
360
2023-10-03T06:41:13Z
Reverie
2
/* Start now! */
wikitext
text/x-wiki
<big>Welcome to Maritime Fiction!</big>
=====What is this?=====
Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company!
=====What do I make here?=====
Feel free to write anything here, ships, captains, shipping lines, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!
=== Start now! ===
[[Special:CreatePage|You can create an article/page by clicking here]]
[https://marfict.miraheze.org/wiki/Special:RecentChanges?hidebots=1&limit=50&days=7&enhanced=1&urlversion=2 Click here to see recent changes made (new article, article edited, logs, etc.)]
[[MarFict:Writing tips|Click here to see the tips to writing an article.]]
5642cb9f77c70326d050e82bd31176df2ae574bf
388
386
2023-10-03T06:45:09Z
Reverie
2
wikitext
text/x-wiki
<big>Welcome to Maritime Fiction!</big>
=====What is this?=====
Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company!
=====What do I make here?=====
Feel free to write anything here, ships, captains, shipping lines, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!
=== Start now! ===
[[Special:CreatePage|You can create an article/page by clicking here]]
[https://marfict.miraheze.org/wiki/Special:RecentChanges?hidebots=1&limit=50&days=7&enhanced=1&urlversion=2 Click here to see recent changes made (new article, article edited, logs, etc.)]
fa90601f29534f1ef4504dfb73bfd1aba5a2107d
391
388
2023-10-03T07:24:21Z
Reverie
2
wikitext
text/x-wiki
<big>Welcome to Maritime Fiction!</big>
=====What is this?=====
Maritime Fiction is a wiki for ship enthusiasts to create their own articles, of their own ships, or their own shipping company!
=====What do I make here?=====
Feel free to write anything here, ships, captains, shipping lines, as long it doesn't violate any of '''Miraheze''''s content policy... Or is maritime related!
=== Start now! ===
[[Special:CreatePage|You can create an article/page by clicking here]]
[https://marfict.miraheze.org/wiki/Special:RecentChanges?hidebots=1&limit=50&days=7&enhanced=1&urlversion=2 Click here to see recent changes made (new article, article edited, logs, etc.)]
[[MarFict:Writing tips|Click here to see the tips to writing an article.]]
5642cb9f77c70326d050e82bd31176df2ae574bf
MarFict:Writing tips
0
170
387
2023-10-03T06:44:24Z
Reverie
2
Created page with "'''Writing an article''' is not easy unless you're experienced. You may have not known what exactly is the format here, or you already know and chose not to insert it, ''which is fine'', but here are the tips to writing a basic article:"
wikitext
text/x-wiki
'''Writing an article''' is not easy unless you're experienced. You may have not known what exactly is the format here, or you already know and chose not to insert it, ''which is fine'', but here are the tips to writing a basic article:
c5b85d7e131842f0933923cbc82d5fd191cb7554
389
387
2023-10-03T07:20:49Z
Reverie
2
wikitext
text/x-wiki
'''Writing an article''' is not easy unless you're experienced. You may have not known what exactly is the format here, or you already know and chose not to insert it, ''which is fine'', but here are the tips to writing a basic article:
=Writing an article=
An article ''atleast'' needs these things: The subject, and something about the subject (describing):<blockquote>SS Ship is a ship.</blockquote>Next, we can add further informations to it:<blockquote>SS Ship is an Antarctic ship built in South Pole, Antarctica. She was built in 2450.</blockquote>'''Always''' make the first mention of the subject bold, and the later mentions can be plain text. '''Every''' mention of a ship's name must be in italic. In this case, we are making it bold italic since it is the first mention of the subject.<blockquote>'''SS ''Ship''''' is an Antarctic ship built in South Pole, Antarctica. She was built in 2450.</blockquote>Let's add some history to it.<blockquote>'''SS ''Ship''''' is an Antarctic ship built in South Pole, Antarctica. She was built in 2450 by the Penguins Builder CO. Her owner is the Penguin Cruise Line. Her sistership is the SS ''Boat'' and ''Vehicle'' of the ''Boat''-class ships, in which is the largest of all three.
Her usual route is from South Pole to the South Sandwich Islands.
</blockquote>Now that we're done with the basic summary on the start of the article, we can progress to sections. Write <nowiki>==</nowiki> to insert a section. In this case, we can't propely display it in here since we're (all of this text) already in a section right now.
<blockquote>'''SS ''Ship''''' is an Antarctic ship built in South Pole, Antarctica. She was built in 2450 by the Penguins Builder CO. Her owner is the Penguin Cruise Line. Her sistership is the SS ''Boat'' and ''Vehicle'' of the ''Boat''-class ships, in which is the largest of all three.
Her usual route is from South Pole to the South Sandwich Islands.
==Design and construction==
<blockquote>''Ship'' was designed by famous architect Penn Guinn, who carefully designed it to not roll over in heavy weathers.
''Ship'' was laid down by Penguins Builder CO. in South Pole, Antarctic on slipway number 999 on December 2448. She was launched in December 2449 and completed on January 2450.
She featured two gigantic funnels with four 3-bladed propellers, which propels her to go 27 knots, though she rather averaged 28.3 knots on average. She had accomodations for 4564 penguins; 4000 penguin class and 564 first class.
==Sinking==
<blockquote>On December 2469, while heading to the South Sandwich Islands, ''Ship'' collided into an iceberg at 4:32 AM 3 kilometres away before reaching her destination. Penguins went into panic and the upper decks were immediately crowded, some even can't move through the massive crowds. Only 8 out of 18 lifeboats were launched, but miraculously Penguincopters arrived and rescued all passengers that are still stuck onboard and there are no deaths in the sinking at all.</blockquote>And now we're done writing a ''brief'' article! You may add more sections for more informations. When you're writing a joke article, please make it as obvious as possible. You may create ships from alternate eras (for example, alternative White Star Ships, ships if WW1 never happened, etc.)
'''Here's something to know when writing an article:'''
* When linking a text to a wikipedia article (for example, you want to link the word Penguin to a wikipedia article), please type "W:" (without quotes) infront of the linked article: <nowiki>[[W:Penguin|Penguin]]</nowiki> (W:Penguin = the Wikipedia article you want to link to, Penguin = the actual word said.) and it will look like this: [[W:Penguin|Penguin]]
ebe868e9ab02e7a5bcd8f41fc128968d77e692f6
390
389
2023-10-03T07:22:46Z
Reverie
2
wikitext
text/x-wiki
'''Writing an article''' is not easy unless you're experienced. You may have not known what exactly is the format here, or you already know and chose not to insert it, ''which is fine'', but here are the tips to writing a basic article:
=Writing an article=
An article ''atleast'' needs these things: The subject, and something about the subject (describing):<blockquote>SS Ship is a ship.</blockquote>Next, we can add further informations to it:<blockquote>SS Ship is an Antarctic ship built in South Pole, Antarctica. She was built in 2450.</blockquote>'''Always''' make the first mention of the subject bold, and the later mentions can be plain text. '''Every''' mention of a ship's name must be in italic. In this case, we are making it bold italic since it is the first mention of the subject.<blockquote>'''SS ''Ship''''' is an Antarctic ship built in South Pole, Antarctica. She was built in 2450.</blockquote>Let's add some history to it.<blockquote>'''SS ''Ship''''' is an Antarctic ship built in South Pole, Antarctica. She was built in 2450 by the Penguins Builder CO. Her owner is the Penguin Cruise Line. Her sistership is the SS ''Boat'' and ''Vehicle'' of the ''Boat''-class ships, in which is the largest of all three.
Her usual route is from South Pole to the South Sandwich Islands.
</blockquote>Now that we're done with the basic summary on the start of the article, we can progress to sections. Write <nowiki>==</nowiki> to insert a section. In this case, we can't propely display it in here since we're (all of this text) already in a section right now.
<blockquote>'''SS ''Ship''''' is an Antarctic ship built in South Pole, Antarctica. She was built in 2450 by the Penguins Builder CO. Her owner is the Penguin Cruise Line. Her sistership is the SS ''Boat'' and ''Vehicle'' of the ''Boat''-class ships, in which is the largest of all three.
Her usual route is from South Pole to the South Sandwich Islands.
<blockquote>==Design and construction==
''Ship'' was designed by famous architect Penn Guinn, who carefully designed it to not roll over in heavy weathers.
''Ship'' was laid down by Penguins Builder CO. in South Pole, Antarctic on slipway number 999 on December 2448. She was launched in December 2449 and completed on January 2450.
She featured two gigantic funnels with four 3-bladed propellers, which propels her to go 27 knots, though she rather averaged 28.3 knots on average. She had accomodations for 4564 penguins; 4000 penguin class and 564 first class.
<blockquote>==Sinking==
On December 2469, while heading to the South Sandwich Islands, ''Ship'' collided into an iceberg at 4:32 AM 3 kilometres away before reaching her destination. Penguins went into panic and the upper decks were immediately crowded, some even can't move through the massive crowds. Only 8 out of 18 lifeboats were launched, but miraculously Penguincopters arrived and rescued all passengers that are still stuck onboard and there are no deaths in the sinking at all.</blockquote>And now we're done writing a ''brief'' article! You may add more sections for more informations. When you're writing a joke article, please make it as obvious as possible. You may create ships from alternate eras (for example, alternative White Star Ships, ships if WW1 never happened, etc.)
'''Here's something to know when writing an article:'''
* When linking a text to a wikipedia article (for example, you want to link the word Penguin to a wikipedia article), please type "W:" (without quotes) infront of the linked article: <nowiki>[[W:Penguin|Penguin]]</nowiki> (W:Penguin = the Wikipedia article you want to link to, Penguin = the actual word said.) and it will look like this: [[W:Penguin|Penguin]]
772362d75d2a9a81eacc500d8d039d4cf5ca04c7
Belle Line
0
171
399
2023-10-04T06:26:01Z
Reverie
2
Created page with "The '''Belle Line''' is a British shipping and cruise line owned by the [[Transoceanic Maritime Company]]. Belle was founded by Edouard Labelle in 1873, who first started by chartering steamships until 1875 when its first ship, PS ''[[PS Belle of Channel (1875)|Belle of Channel]]'' was built. In 1904, Belle relocated from [[W:Liverpool|Liverpool]] to [[W:Southampton|Southampton]], to better cater to Londoners. On behalf of the great depression, Belle was forced to scrap..."
wikitext
text/x-wiki
The '''Belle Line''' is a British shipping and cruise line owned by the [[Transoceanic Maritime Company]]. Belle was founded by Edouard Labelle in 1873, who first started by chartering steamships until 1875 when its first ship, PS ''[[PS Belle of Channel (1875)|Belle of Channel]]'' was built. In 1904, Belle relocated from [[W:Liverpool|Liverpool]] to [[W:Southampton|Southampton]], to better cater to Londoners.
On behalf of the great depression, Belle was forced to scrap ships from its fleet in order to secure its loans to the British Government. In 1937, the ''[[RMS Belle of England (1937)|Belle of England]]'' and ''[[RMS Belle of Scotland (1936)|Belle of Scotland]]'' was built which increased Belle's popularity which opened the opportunity to compete with new rivals. In 1939, while constructing its new superliner, ''Belle of Britain'', the [[W:Second World War|Second World War]] broke out and thus her construction was rushed to completion as a [[W:Troop ship|troop ship]].
Belle is now currently known for its "modern liners", such as the ''[[MS Mariana (1994)|Mariana]]'' (II), ''[[MS Belle Grandeur|Belle Grandeur]]'', and ''[[MS Belle Honour|Belle Honour]]''. In 2019, a new ship to the fleet was announced, named ''[[MS Gibraltar|Gibraltar]],'' initially scheduled by 2023, but due to the COVID-19 pandemic it was rescheduled to 2025.
e89c8099aaa1033d02df2f443a72985f147980da
MS Gibraltar
0
172
400
2023-10-04T06:43:25Z
Reverie
2
Created page with "'''MS ''Gibraltar''''' is a cruise ship under construction for [[Belle Line]]. == History == In 2019, Belle announced the order of fifth ship in their current fleet and the 132nd ship in its history. It was initially announced that the new vessel will be 1062 ft (324 m) long and can carry to over 2670 passengers. In January 2020, Belle annouced the design and demonstration of ''Gibraltar''. Steel cutting began at the W:Chantiers de l'Atlantique|Chantiers de l'Atlant..."
wikitext
text/x-wiki
'''MS ''Gibraltar''''' is a cruise ship under construction for [[Belle Line]].
== History ==
In 2019, Belle announced the order of fifth ship in their current fleet and the 132nd ship in its history. It was initially announced that the new vessel will be 1062 ft (324 m) long and can carry to over 2670 passengers.
In January 2020, Belle annouced the design and demonstration of ''Gibraltar''. Steel cutting began at the [[W:Chantiers de l'Atlantique|Chantiers de l'Atlantique]] shipyard at Saint-Nazaire on 23 June 2021. It was estimated to be completed by 2022. However, due to the COVID-19 Pandemic, it was delayed to 2023. Another major milestone was reached on 2 February 2023, as the partially-completed ship was launched, by Rose Thompson, wife of Harry Labelle, current chairman of the Belle Line.
The media initially speculated whether the ship's name would continue with Belle's iconic ''Belle of''- name like past ships ''Belle of England'', ''Belle of London'', ''Belle of Channel'' and ''Belle of Bristol'' or not. Belle annouced the name to be ''Gibraltar''. On 26 August 2023 Belle annouced that ''Gibraltar''<nowiki/>'s maiden voyage would be scheduled on 3 January 2025.
989d07650d79a0a82164d6642601ca2a9e7ef9b8